

version 18
clear all
set more off





* Check if EstSample.dta already exists
capture confirm file "S:/Datos/EstSample.dta"

if _rc {
    di as txt "Estimation sample not found; attempting to build it..."
	
    do "Data Construction/Scripts/EstSample.do"
}
else {
    di as txt "Estimation sample found. Skipping data construction."
}


use "S:/Datos/EstSample.dta", clear




cap drop ref
g ref=1
label var ref"2017"



local begdate 2015 
local enddate 2021  

local twlist"TWITExp_A0 TWRTExp_A0 TWITExpUS_Mex TWRTImpUS_Mex TWITImpCHN_A0 TWRTImpUS_A0 TWITImpUS_A0 TWITExpUS_A0"

foreach tw of local twlist {
		forval i=`begdate'(1)`enddate'{
	label var IMM_`tw'_`i' "`i'"
label var `tw'_`i' "`i'"
}
}	

global TWITEXP"TWITExp_A0_2015 TWITExp_A0_2016  TWITExp_A0_2018 TWITExp_A0_2019 TWITExp_A0_2020 TWITExp_A0_2021"
global TWRTExp"TWRTExp_A0_2015 TWRTExp_A0_2016 TWRTExp_A0_2018 TWRTExp_A0_2019 TWRTExp_A0_2020 TWRTExp_A0_2021"
global TWITMex"TWITExpUS_Mex_2015 TWITExpUS_Mex_2016 TWITExpUS_Mex_2018 TWITExpUS_Mex_2019 TWITExpUS_Mex_2020 TWITExpUS_Mex_2021"
global TWRTMex"TWRTImpUS_Mex_2015 TWRTImpUS_Mex_2016 TWRTImpUS_Mex_2018 TWRTImpUS_Mex_2019 TWRTImpUS_Mex_2020 TWRTImpUS_Mex_2021"
global TWITImpCHN"TWITImpCHN_A0_2015 TWITImpCHN_A0_2016 TWITImpCHN_A0_2018 TWITImpCHN_A0_2019 TWITImpCHN_A0_2020 TWITImpCHN_A0_2021"
global TWRTImpUS"TWRTImpUS_A0_2015 TWRTImpUS_A0_2016 TWRTImpUS_A0_2018 TWRTImpUS_A0_2019 TWRTImpUS_A0_2020 TWRTImpUS_A0_2021"
global TWITImpUS"TWITImpUS_A0_2015 TWITImpUS_A0_2016 TWITImpUS_A0_2018 TWITImpUS_A0_2019 TWITImpUS_A0_2020 TWITImpUS_A0_2021"



global IMM_TWITEXP"IMM_TWITExp_A0_2015 IMM_TWITExp_A0_2016  IMM_TWITExp_A0_2018 IMM_TWITExp_A0_2019 IMM_TWITExp_A0_2020 IMM_TWITExp_A0_2021"
global IMM_TWRTExp"IMM_TWRTExp_A0_2015 IMM_TWRTExp_A0_2016 IMM_TWRTExp_A0_2018 IMM_TWRTExp_A0_2019 IMM_TWRTExp_A0_2020 IMM_TWRTExp_A0_2021"
global IMM_TWITMex"IMM_TWITExpUS_Mex_2015 IMM_TWITExpUS_Mex_2016 IMM_TWITExpUS_Mex_2018 IMM_TWITExpUS_Mex_2019 IMM_TWITExpUS_Mex_2020 IMM_TWITExpUS_Mex_2021"
global IMM_TWRTMex"IMM_TWRTImpUS_Mex_2015 IMM_TWRTImpUS_Mex_2016 IMM_TWRTImpUS_Mex_2018 IMM_TWRTImpUS_Mex_2019 IMM_TWRTImpUS_Mex_2020 IMM_TWRTImpUS_Mex_2021"
global IMM_TWITImpCHN"IMM_TWITImpCHN_A0_2015 IMM_TWITImpCHN_A0_2016 IMM_TWITImpCHN_A0_2018 IMM_TWITImpCHN_A0_2019 IMM_TWITImpCHN_A0_2020 IMM_TWITImpCHN_A0_2021"
global IMM_TWRTImpUS"IMM_TWRTImpUS_A0_2015 IMM_TWRTImpUS_A0_2016 IMM_TWRTImpUS_A0_2018 IMM_TWRTImpUS_A0_2019 IMM_TWRTImpUS_A0_2020 IMM_TWRTImpUS_A0_2021"
global IMM_TWITImpUS"IMM_TWITImpUS_A0_2015 IMM_TWITImpUS_A0_2016 IMM_TWITImpUS_A0_2018 IMM_TWITImpUS_A0_2019 IMM_TWITImpUS_A0_2020 IMM_TWITImpUS_A0_2021"


global TWITEXP_Coefs"TWITExp_A0_2015 TWITExp_A0_2016 ref TWITExp_A0_2018 TWITExp_A0_2019 TWITExp_A0_2020 TWITExp_A0_2021"
global TWRTExp_Coefs"TWRTExp_A0_2015 TWRTExp_A0_2016 ref TWRTExp_A0_2018 TWRTExp_A0_2019 TWRTExp_A0_2020 TWRTExp_A0_2021"
global TWITMex_Coefs"TWITExpUS_Mex_2015 TWITExpUS_Mex_2016 ref TWITExpUS_Mex_2018 TWITExpUS_Mex_2019 TWITExpUS_Mex_2020 TWITExpUS_Mex_2021"
global TWRTMex_Coefs"TWRTImpUS_Mex_2015 TWRTImpUS_Mex_2016 ref TWRTImpUS_Mex_2018 TWRTImpUS_Mex_2019 TWRTImpUS_Mex_2020 TWRTImpUS_Mex_2021"
global TWITImpCHN_Coefs"TWITImpCHN_A0_2015 TWITImpCHN_A0_2016 ref TWITImpCHN_A0_2018 TWITImpCHN_A0_2019 TWITImpCHN_A0_2020 TWITImpCHN_A0_2021"
global TWRTImpUS_Coefs"TWRTImpUS_A0_2015 TWRTImpUS_A0_2016 ref TWRTImpUS_A0_2018 TWRTImpUS_A0_2019 TWRTImpUS_A0_2020 TWRTImpUS_A0_2021"
global TWITImpUS_Coefs"TWITImpUS_A0_2015 TWITImpUS_A0_2016 ref TWITImpUS_A0_2018 TWITImpUS_A0_2019 TWITImpUS_A0_2020 TWITImpUS_A0_2021"



global IMM_TWITEXP_Coefs"IMM_TWITExp_A0_2015 IMM_TWITExp_A0_2016 ref IMM_TWITExp_A0_2018 IMM_TWITExp_A0_2019 IMM_TWITExp_A0_2020 IMM_TWITExp_A0_2021"
global IMM_TWRTExp_Coefs"IMM_TWRTExp_A0_2015 IMM_TWRTExp_A0_2016 ref IMM_TWRTExp_A0_2018 IMM_TWRTExp_A0_2019 IMM_TWRTExp_A0_2020 IMM_TWRTExp_A0_2021"
global IMM_TWITMex_Coefs"IMM_TWITExpUS_Mex_2015 IMM_TWITExpUS_Mex_2016 ref  IMM_TWITExpUS_Mex_2018 IMM_TWITExpUS_Mex_2019 IMM_TWITExpUS_Mex_2020 IMM_TWITExpUS_Mex_2021"
global IMM_TWRTMex_Coefs"IMM_TWRTImpUS_Mex_2015 IMM_TWRTImpUS_Mex_2016 ref  IMM_TWRTImpUS_Mex_2018 IMM_TWRTImpUS_Mex_2019 IMM_TWRTImpUS_Mex_2020 IMM_TWRTImpUS_Mex_2021"
global IMM_TWITImpCHN_Coefs"IMM_TWITImpCHN_A0_2015 IMM_TWITImpCHN_A0_2016 ref  IMM_TWITImpCHN_A0_2018 IMM_TWITImpCHN_A0_2019 IMM_TWITImpCHN_A0_2020 IMM_TWITImpCHN_A0_2021"
global IMM_TWRTImpUS_Coefs"IMM_TWRTImpUS_A0_2015 IMM_TWRTImpUS_A0_2016 ref  IMM_TWRTImpUS_A0_2018 IMM_TWRTImpUS_A0_2019 IMM_TWRTImpUS_A0_2020 IMM_TWRTImpUS_A0_2021"
global IMM_TWITImpUS_Coefs"IMM_TWITImpUS_A0_2015 IMM_TWITImpUS_A0_2016 ref IMM_TWITImpUS_A0_2018 IMM_TWITImpUS_A0_2019 IMM_TWITImpUS_A0_2020 IMM_TWITImpUS_A0_2021"






local filename `"Results.xlsx"'

local refyear 2017


label var IMM_Ref"IMMEX Firms as of the Reference Year 2017"
label var PROSEC_ref"Firms with Preferential Duty License (PROSEC) as of the Reference Year"
label var export"Export Dummy"
label var import"Import Dummy"
label var f_X_HS6"Number of Goods (HS6) Exported"
label var f_M_HS6"Number of Goods (HS6) Imported"
label var N_X_CO"Number of Countries Exported"
label var N_M_CO"Number of Countries Imported"
label var lnExportUSD"Log Value of Exports" 
label var lnImportUSD"Log Value of Imports"


label var TWITExp_A0"TM^{US-CN}"
label var TWRTExp_A0"TX^{CN-US}"
label var TWITExpUS_Mex"TM^{US-MEX}"
label var TWRTImpUS_Mex"TX^{MEX-US}"
label var TWITImpCHN_A0"IMCN^{USIT}"
label var TWITImpUS_A0"IC^{USIT}"
label var TWRTImpUS_A0"IC^{USRT}"
label var TWITExpUS_A0"TMA^{US-CN} / US-market specific tariff exposure (Eq C.1)"

label var PostTWITExp_A0"Post2018 x TM^{US-CN}"
label var PostTWRTExp_A0"Post2018 x TX^{CN-US}"
label var PostTWITExpUS_Mex "Post2018 x TM^{US-MEX}"
label var PostTWRTImpUS_Mex "Post2018 x TX^{MEX-US}"


label var tot98 "Imports under special heading"
label var c98_USA "Imports under special heading from USA"
label var c98_EU28 "Imports under special heading from EU28"
label var c98_LAC "Imports under special heading from Latin America"
label var c98_CHN "Imports under special heading from China"
label var c98_OTHAS "Imports under special heading from Other Asia"

local xlist"USA CAN LAC EU28 CHN OTHAS"
foreach x of local xlist{
	label var `x'_xsh" `x' Share in Firm's Exports" 
		label var `x'_msh" `x' Share in Firm's Imports" 
}
 



label var MXFirmC"Domestic or not identified owner"
label var fparC"Foreign owned" 
label var USParC"US owned" 
label var EU28ParC"EU-28 owned" 
label var OTHASParC"Other Asia owned"
label var CNParC"China owned"

*Table 1 Summary Statistics
global vlist "IMM_Ref PROSEC_ref  export import f_X_HS6 f_M_HS6 N_X_CO N_M_CO lnExportUSD lnImportUSD"


putexcel set `filename', sheet("Table1") replace
putexcel A1=("Variable") B1=("Variable") C1=("Mean") D1=("Median")  E1=("SD") F1=("Min") G1=("Max") H1=("Obs")
local row=2
foreach var of varlist $vlist{
	qui sum `var' if year==`refyear', d
	local varlabel: var label `var'
	qui putexcel A`row'=("`varlabel'")
		qui putexcel B`row'=("`var'")
	qui putexcel C`row'=(r(mean))
	qui putexcel D`row'=(r(p50))
	qui putexcel E`row'=(r(sd))
	qui putexcel F`row'=(r(min))
	qui putexcel G`row'=(r(max))
	qui putexcel H`row'=(r(N))
	local ++row
	
}

putexcel set `filename', sheet("Table1") modify
putexcel A18=("IMMEX") B18=("Variable") C18=("Mean") D18=("Median")  E18=("SD") F18=("Min") G18=("Max") H18=("Obs")
local row=19
foreach var of varlist $vlist{
	qui sum `var' if IMM_Ref==1 &   year==`refyear', d


	qui putexcel A`row'=("`varlabel'")
	qui putexcel B`row'=("`var'")
	qui putexcel C`row'=(r(mean))
	qui putexcel D`row'=(r(p50))
	qui putexcel E`row'=(r(sd))
	qui putexcel F`row'=(r(min))
	qui putexcel G`row'=(r(max))
	qui putexcel H`row'=(r(N))
	local ++row
	
}


*Figure 1


reghdfe lnExportUSD $TWITEXP_Coefs $TWRTExp $TWITMex $TWRTMex [aweight=lnxweight], vce(cluster ID) absorb(ID  year NonManu_yr  fsize_yr )
est store x_all_w


reghdfe lnUSAExport $TWITEXP_Coefs $TWRTExp $TWITMex $TWRTMex [aweight=lnxweight], vce(cluster ID) absorb(ID  year NonManu_yr  fsize_yr )
est store usx_all_w

reghdfe lnNonUSExport $TWITEXP_Coefs $TWRTExp $TWITMex $TWRTMex [aweight=lnxweight], vce(cluster ID) absorb(ID  year NonManu_yr  fsize_yr )
est store nonusx_all_w

outreg2 [x_all_w usx_all_w nonusx_all_w]  using Fig1Data.xls, replace keep($TWITEXP) append addtext(Concurrent Policy Controls, yes, Firm FE, yes, Time FE, yes, NonManu x Year, yes, Baseline Firm Size x Year, yes, weighted, yes) nocons dec(3) dta




coefplot (usx_all_w, label("Dep. Var. Log US Exports")  msymbol(Sh) msize(medium) lcolor(black) mcolor(black) ciopts(lcolor(gs5))), ///
keep($TWITEXP_Coefs) vertical omit graphregion(fcolor(white) lcolor(white)) coeflabels(, angle(45)) yline(0,  lpattern(solid))  /// 
ytitle("Firms' Exposure to US Tariffs on China") legend(cols(1) ring(0) pos(11) size(small)) ylabel(-0.5 (0.25) 1.25) 
graph export "Figure1.pdf", replace


**Figure B1

coefplot (nonusx_all_w, label("Dep. Var. Log Non-US Exports")  msymbol(Th) msize(medium) lcolor(navy) mcolor(navy) ciopts(lcolor(navy)) ), ///
keep($TWITEXP_Coefs) vertical omit graphregion(fcolor(white) lcolor(white)) coeflabels(, angle(45)) yline(0,  lpattern(solid))  /// 
ytitle("Firms' Exposure to US Tariffs on China") legend(cols(1) ring(0) pos(11) size(small)) ylabel(-2.25 (1) 2.25) nooffset 
graph export "FigureB1.pdf", replace








*Figure 2




reghdfe lnUSAExport  $TWITEXP_Coefs $IMM_TWITEXP $TWRTExp $IMM_TWRTExp $TWITMex $IMM_TWITMex $TWRTMex $IMM_TWRTMex , vce(cluster ID) absorb(ID  NonManu_yr  IMM_Ref_yr fsize_yr )
est store usx
outreg2 using TableB2.xls, replace keep($TWITEXP $IMM_TWITEXP) addtext(Concurrent Policy Controls, yes, Firm FE, yes, Time FE, yes, NonManu x Year, yes, Baseline Firm Size x Year, yes, weighted, no) nocons dec(3) dta symbol(^{a}, ^{b}, ^{c}) alpha(0.01, 0.05, 0.10)

reghdfe lnUSAExport  $TWITEXP_Coefs $IMM_TWITEXP $TWRTExp $IMM_TWRTExp $TWITMex $IMM_TWITMex $TWRTMex $IMM_TWRTMex [aweight=lnxweight], vce(cluster ID) absorb(ID  NonManu_yr  IMM_Ref_yr fsize_yr )
est store usx_w
outreg2 using TableB2.xls, append keep($TWITEXP $IMM_TWITEXP) addtext(Concurrent Policy Controls, yes, Firm FE, yes, Time FE, yes, NonManu x Year, yes, Baseline Firm Size x Year, yes, weighted, yes) nocons dec(3) dta symbol(^{a}, ^{b}, ^{c}) alpha(0.01, 0.05, 0.10)

reghdfe lnExportUSD  $TWITEXP_Coefs $IMM_TWITEXP $TWRTExp $IMM_TWRTExp $TWITMex $IMM_TWITMex $TWRTMex $IMM_TWRTMex , vce(cluster ID) absorb(ID   NonManu_yr IMM_Ref_yr fsize_yr )
est store x
outreg2 using TableB2.xls, append keep($TWITEXP $IMM_TWITEXP) addtext(Concurrent Policy Controls, yes, Firm FE, yes, Time FE, yes, NonManu x Year, yes, Baseline Firm Size x Year, yes, weighted, no) nocons dec(3) dta symbol(^{a}, ^{b}, ^{c}) alpha(0.01, 0.05, 0.10)

reghdfe lnExportUSD  $TWITEXP_Coefs $IMM_TWITEXP $TWRTExp $IMM_TWRTExp $TWITMex $IMM_TWITMex $TWRTMex $IMM_TWRTMex [aweight=lnxweight], vce(cluster ID) absorb(ID   NonManu_yr IMM_Ref_yr fsize_yr )
est store x_w
outreg2 using TableB2.xls, append keep($TWITEXP $IMM_TWITEXP) addtext(Concurrent Policy Controls, yes, Firm FE, yes, Time FE, yes, NonManu x Year, yes, Baseline Firm Size x Year, yes, weighted, yes) nocons dec(3) dta symbol(^{a}, ^{b}, ^{c}) alpha(0.01, 0.05, 0.10)



outreg2 [usx_w x_w] using Fig2Data.xls, replace keep($TWITEXP $IMM_TWITEXP)  nocons dec(3) dta

coefplot (x_w, label("Dep. Var. Log Worldwide Exports")  msymbol(Oh) msize(medium)  lcolor(black) mcolor(black) ciopts(lcolor(gs5)) offset(-0.05)) ///
(usx_w, label("Dep. Var. Log US Exports") msymbol(Sh)  msize(medium) lcolor(black) mcolor(black) ciopts(lcolor(gs5)) offset(0.05)), ///
keep($TWITEXP_Coefs) vertical omit graphregion(fcolor(white) lcolor(white)) coeflabels(, angle(45)) yline(0,  lpattern(solid))  /// 
ytitle("Firms' Exposure to US Tariffs on China""Common Effect (DD)") legend(cols(1) ring(0) pos(10) size(small)) ylabel(-0.75 (0.25) 2.25) 
graph export "Figure2a.pdf", replace


reghdfe lnExportUSD  $TWITEXP $IMM_TWITEXP_Coefs $TWRTExp $IMM_TWRTExp $TWITMex $IMM_TWITMex $TWRTMex $IMM_TWRTMex [aweight=lnxweight], vce(cluster ID) absorb(ID  year NonManu_yr IMM_Ref_yr fsize_yr )
est store x_w

reghdfe lnUSAExport  $TWITEXP $IMM_TWITEXP_Coefs $TWRTExp $IMM_TWRTExp $TWITMex $IMM_TWITMex $TWRTMex $IMM_TWRTMex [aweight=lnxweight], vce(cluster ID) absorb(ID  year NonManu_yr IMM_Ref_yr fsize_yr )
est store usx_w

coefplot (x_w, label("Dep. Var. Log Worldwide Exports")   msymbol(Oh) msize(medium)  lcolor(black) mcolor(black) ciopts(lcolor(gs5)) offset(-0.05)) ///
(usx_w, label("Dep. Var. Log US Exports") msymbol(Sh)  msize(medium) lcolor(black) mcolor(black) ciopts(lcolor(gs5)) offset(0.05)), ///
keep($IMM_TWITEXP_Coefs) vertical omit graphregion(fcolor(white) lcolor(white)) coeflabels(, angle(45)) yline(0,  lpattern(solid))  /// 
ytitle("Disproportionate Impact on GVCs""DDD Coefs") legend(cols(1) ring(0) pos(10) size(small)) ylabel(-0.75 (0.25) 2.25) 
graph export "Figure2b.pdf", replace






**Figure B.2


reghdfe lnExportUSD  $TWITEXP $IMM_TWITEXP $TWRTExp_Coefs $IMM_TWRTExp $TWITMex $IMM_TWITMex $TWRTMex $IMM_TWRTMex [aweight=lnxweight], vce(cluster ID) absorb(ID  year NonManu_yr IMM_Ref_yr fsize_yr )
est store x1_w
outreg2  using "FigB2Data.xls", replace keep($TWRTExp_Coefs) ctitle(Exports) title("Impact of China's Retaliatory Tariffs on US Goods")  nocons dec(3) dta label 

reghdfe lnUSAExport  $TWITEXP $IMM_TWITEXP $TWRTExp_Coefs $IMM_TWRTExp $TWITMex $IMM_TWITMex $TWRTMex $IMM_TWRTMex [aweight=lnxweight], vce(cluster ID) absorb(ID  year NonManu_yr  IMM_Ref_yr fsize_yr )
est store usx1_w
outreg2  using "FigB2Data.xls", append keep($TWRTExp_Coefs) ctitle(USExports)   nocons dec(3) dta label 



reghdfe lnExportUSD  $TWITEXP $IMM_TWITEXP $TWRTExp $IMM_TWRTExp_Coefs $TWITMex $IMM_TWITMex $TWRTMex $IMM_TWRTMex [aweight=lnxweight], vce(cluster ID) absorb(ID  year NonManu_yr IMM_Ref_yr fsize_yr )
est store x2_w
outreg2  using "FigB2Data.xls", append keep($IMM_TWRTExp_Coefs) ctitle(Exports-Disp Eff on GVC)   nocons dec(3) dta label 


reghdfe lnUSAExport  $TWITEXP $IMM_TWITEXP $TWRTExp $IMM_TWRTExp_Coefs $TWITMex $IMM_TWITMex $TWRTMex $IMM_TWRTMex [aweight=lnxweight], vce(cluster ID) absorb(ID  year NonManu_yr IMM_Ref_yr fsize_yr )
est store usx2_w
outreg2  using "FigB2Data.xls", append keep($IMM_TWRTExp_Coefs) ctitle(USExports-Disp Eff on GVC)   nocons dec(3) dta label 



coefplot (x1_w, label("Dep. Var. Log Worldwide Exports")  msymbol(Oh) msize(medium) lcolor(brown) mcolor(brown) ciopts(lcolor(brown)) offset(-0.05)) ///
(usx1_w, label("Dep. Var. Log US Exports") msymbol(Sh) msize(medium) lcolor(sienna) mcolor(sienna) ciopts(lcolor(sienna)) offset(0.05)), ///
keep($TWRTExp_Coefs) vertical omit graphregion(fcolor(white) lcolor(white)) coeflabels(, angle(45)) yline(0,  lpattern(solid))   ///
ytitle("Firms' Exposure to China's Tariffs on US""DD Coefficients") legend(cols(1) ring(0) pos(2) size(small)) ylabel(-1.25 (0.25) 1.25) 
graph export "FigureB2a.pdf", replace // Fig_ddd_xusx_twrt_w.pdf




coefplot (x2_w, label("Dep. Var. Log Worldwide Exports")  msymbol(Oh)  msize(medium) lcolor(brown) mcolor(brown) ciopts(lcolor(brown)) offset(-0.05)) ///
(usx2_w, label("Dep. Var. Log US Exports") msymbol(Sh) msize(medium) lcolor(sienna) mcolor(sienna) ciopts(lcolor(sienna)) offset(0.05)), ///
keep(IMM_TWRTExp_A0_2015 IMM_TWRTExp_A0_2016 ref IMM_TWRTExp_A0_2018 IMM_TWRTExp_A0_2019 IMM_TWRTExp_A0_2020 IMM_TWRTExp_A0_2021) vertical omit graphregion(fcolor(white) lcolor(white)) coeflabels(, angle(45)) yline(0,  lpattern(solid))  /// recast(connected)
ytitle("Firms' Exposure to China's Tariffs on US""Disproportionate Impact on GVCs, DDD Coefficients") legend(cols(1) ring(0) pos(2) size(small)) ylabel(-1.25 (0.25) 1.25) 
graph export "FigureB2b.pdf", replace //Fig_ddd_xusx_twrt_imm_w.pdf


***Figure 3. Impact of US Tariffs Targating China on GVC Firms' Exports to the US


reghdfe lnUSAExport $TWITEXP_Coefs $TWRTExp $TWITMex $TWRTMex   if  IMM_Ref==1, vce(cluster ID) absorb(ID  year  naics1_yr fsize_yr)
est store usx
	outreg2  using "FigB3Data.xls", replace keep($TWITEXP_Coefs) addtext(Firm FE, YES, Year FE, YES,  Baseline Firm Size  x Year FE, YES, NAICS1 x Year, YES)  nocons dec(3) dta label 
	

reghdfe lnTotUSExNetOfCN $TWITEXP_Coefs $TWRTExp $TWITMex $TWRTMex   if  IMM_Ref==1, vce(cluster ID) absorb(ID  year  naics1_yr fsize_yr)
est store usx_netch



coefplot (usx, label("Dep. var. Log US Exports")  msymbol(Dh) msize(medium) lcolor(black) mcolor(black) ciopts(lcolor(gs5)) offset(-0.07)) ///
(usx_netch, label("Dep. var. Log US Exports Net of CN Imports")  msymbol(O) msize(medium) lcolor(black) mcolor(black) ciopts(lcolor(gs5)) offset(0.07)), ///
keep($TWITEXP_Coefs ) vertical omit graphregion(fcolor(white) lcolor(white)) coeflabels(, angle(45)) yline(0,  lpattern(solid))  /// 
ytitle("Firms' Exposure to US Tariffs on China") legend(cols(1) ring(0) pos(11) size(small)) ylabel(-0.5 (0.25) 2.5) nooffset recast(connected)


graph export "Figure3.pdf", replace     


outreg2 [usx usx_netch] using Fig3Data.xls, replace keep($TWITEXP)  nocons dec(3) dta label



**Figure B.3
reghdfe lnUSAExport $TWITEXP_Coefs $TWRTExp $TWITMex $TWRTMex   if  IMM_Ref==1, vce(cluster ID) absorb(ID  year  naics2_yr fsize_yr)
est store usx_ind2
	outreg2  using "FigB3Data.xls", append keep($TWITEXP_Coefs) ctitle("FigB3") addtext(Firm FE, YES, Year FE, YES,  Baseline Firm Size  x Year FE, YES, NAICS2 x Year, YES)  nocons dec(3) dta label
	
reghdfe lnUSAExport $TWITEXP_Coefs $TWRTExp $TWITMex $TWRTMex   if  IMM_Ref==1, vce(cluster ID) absorb(ID  year  naics3_yr fsize_yr)
est store usx_ind3
	outreg2  using "FigB3Data.xls", append keep($TWITEXP_Coefs) ctitle("FigB3") addtext(Firm FE, YES, Year FE, YES,  Baseline Firm Size  x Year FE, YES, NAICS3 x Year, YES)  nocons dec(3) dta label



coefplot (usx, label("w/ 1-dig NAICS x Year FEs")  msymbol(Oh) msize(medium) lcolor(green) mcolor(green) ciopts(lcolor(green)) offset(-0.05) ) ///
(usx_ind2, label("w/ 2-dig NAICS x Year FEs") msymbol(Sh) msize(medium) lcolor(orange) mcolor(orange) ciopts(lcolor(orange)) offset(0.0)) ///
(usx_ind3, label("w/ 3-dig NAICS x Year FEs") msymbol(Dh) msize(medium) lcolor(blue) mcolor(blue) ciopts(lcolor(blue)) offset(0.05)), ///
keep($TWITEXP_Coefs ) vertical omit graphregion(fcolor(white) lcolor(white)) coeflabels(, angle(45)) yline(0,  lpattern(solid))  /// 
ytitle("Firms' Exposure to US Tariffs on China") legend(cols(1) ring(0) pos(11) size(small)) ylabel(-0.5 (0.25) 2.5) recast(connected)

graph export "FigureB3.pdf", replace // Fig_gvc_usx_ind




**Figure B.4




reghdfe lnExportUSD $TWITEXP_Coefs $TWRTExp $TWITMex $TWRTMex   if  IMM_Ref==1, vce(cluster ID) absorb(ID  year  naics1_yr fsize_yr)
est store totx
outreg2 using "FigB4Data.xls", append ctitle("FigB4a") keep($TWITEXP_Coefs)  addtext(Firm FE, YES, Year FE, YES,  Baseline Firm Size x Year FE, YES, NAICS1 x Year, YES)  nocons dec(3) dta label 


reghdfe lnNonUSExport $TWITEXP_Coefs $TWRTExp $TWITMex $TWRTMex   if  IMM_Ref==1, vce(cluster ID) absorb(ID  year  naics1_yr fsize_yr)
est store nonusx
outreg2 using "FigB4Data.xls", append ctitle("FigB4b") keep($TWITEXP_Coefs)  addtext(Firm FE, YES, Year FE, YES,  Baseline Firm Size  x Year FE, YES, NAICS1 x Year, YES)  nocons dec(3) dta label



coefplot (totx, label("Dep. var. Log Worldwide Exports") msymbol(Oh) msize(medium) lcolor(blue) mcolor(blue) ciopts(lcolor(blue))), ///
keep($TWITEXP_Coefs ) vertical omit graphregion(fcolor(white) lcolor(white)) coeflabels(, angle(45)) yline(0,  lpattern(solid))  /// 
ytitle("Firms' Exposure to US Tariffs on China") legend(cols(1) ring(0) pos(11) size(small)) ylabel(-0.5 (0.25) 2) nooffset recast(connected)
graph export "FigureB4a.pdf", replace //Fig_gvc_x.pdf



coefplot (nonusx, label("Dep. var. Log Non-US Exports")  msymbol(Dh) msize(medium) lcolor(blue) mcolor(blue) ciopts(lcolor(blue)) ), ///
keep($TWITEXP_Coefs ) vertical omit graphregion(fcolor(white) lcolor(white)) coeflabels(, angle(45)) yline(0,  lpattern(solid))  /// 
ytitle("Firms' Exposure to US Tariffs on China") legend(cols(1) ring(0) pos(11) size(small)) ylabel(-7.5 (2) 7.5) nooffset recast(connected)

graph export "FigureB4b.pdf", replace


**Figure B.5


reghdfe lnExportUSD  $TWITEXP $TWRTExp_Coefs $TWITMex $TWRTMex   if  IMM_Ref==1 , vce(cluster ID) absorb(ID  year  naics1_yr fsize_yr)
est store g_lnx

reghdfe lnExportUSD  $TWITEXP $TWRTExp_Coefs $TWITMex $TWRTMex   if  IMM_Ref==1 , vce(cluster ID) absorb(ID  year  naics3_yr fsize_yr)
est store g_lnx_3dig

outreg2 [g_lnx g_lnx_3dig] using "FigB5Data.xls", replace  title("Effect of China's Retaliatory Tariffs") keep($TWRTExp)  addtext(Firm FE, YES, Year FE, YES,  Baseline Firm Size  x Year FE, YES, NAICS1 x Year, YES)  nocons dec(3) dta 


coefplot (g_lnx, label("Dep. var. Log Total Exports, baseline")  msymbol(Dh) msize(medium) lcolor(sienna) mcolor(sienna) ciopts(lcolor(sienna)) offset(-0.07)) ///
(g_lnx_3dig, label("Dep. var. Log Total Exports, w/ 3-digit NAICS x Year FEs")  msymbol(D) msize(medium) lcolor(sienna) mcolor(sienna) ciopts(lcolor(sienna)) offset(0.07) ), ///
keep($TWRTExp_Coefs ) vertical omit graphregion(fcolor(white) lcolor(white)) coeflabels(, angle(45)) yline(0,  lpattern(solid))  /// xline(3.25, lcolor(gs10)) recast(connected)
ytitle("Firms' Exposure to China's Tariffs on US") legend(cols(1) ring(0) pos(11) size(small)) ylabel(-2 (0.25) 1.25) nooffset 
graph export "FigureB5.pdf", replace  //Fig_gvc_lnx_r3dig_twrt.pdf



**Figure B.6


	
reghdfe IHS_NetExport $TWITEXP_Coefs $TWRTExp $TWITMex $TWRTMex   if  IMM_Ref==1, vce(cluster ID) absorb(ID  year  naics1_yr fsize_yr)
est store ihsnetx
outreg2 using "FigB6Data.xls", replace  keep($TWITEXP_Coefs)  addtext(Firm FE, YES, Year FE, YES,  Baseline Firm Size  x Year FE, YES, NAICS1 x Year, YES)  nocons dec(3) dta 


reghdfe IHS_ExpNetOfImp $TWITEXP_Coefs $TWRTExp $TWITMex $TWRTMex   if  IMM_Ref==1, vce(cluster ID) absorb(ID  year  naics1_yr fsize_yr)
est store ihsnetexpl
outreg2 using "FigB6Data.xls", append  keep($TWITEXP_Coefs)  addtext(Firm FE, YES, Year FE, YES,  Baseline Firm Size  x Year FE, YES, NAICS1 x Year, YES)  nocons dec(3) dta 



coefplot (ihsnetexpl, label("Dep. var. (ihs)  Net Exports (Product Level)")  msymbol(Dh) msize(medium) lcolor(blue) mcolor(blue) ciopts(lcolor(blue)) ), ///
keep($TWITEXP_Coefs ) vertical omit graphregion(fcolor(white) lcolor(white)) coeflabels(, angle(45)) yline(0,  lpattern(solid))  /// 
ytitle("Firms' Exposure to US Tariffs on China") legend(cols(1) ring(0) pos(11) size(small)) ylabel(-4 (2) 13) nooffset recast(connected)

graph export "FigureB6a.pdf", replace  // Fig_gvc_ihsnetexpl.pdf




coefplot (ihsnetx, label("Dep. var. (ihs) Net Exports (X-M)")  msymbol(Oh) msize(medium) lcolor(blue) mcolor(blue) ciopts(lcolor(blue)) ), ///
keep($TWITEXP_Coefs ) vertical omit graphregion(fcolor(white) lcolor(white)) coeflabels(, angle(45)) yline(0,  lpattern(solid))  /// 
ytitle("Firms' Exposure to US Tariffs on China") legend(cols(1) ring(0) pos(11) size(small)) ylabel(-4 (2) 13) nooffset recast(connected)

graph export "FigureB6b.pdf", replace // Fig_gvc_ihsnetx.pdf


**Figure 4 regression



reghdfe lnExportUSD PostTWITExp_A0 PostTWRTExp_A0 $TWITMex $TWRTMex if  IMM_Ref==1 & (naics1_ref==1 | naics1_ref==2), vce(cluster ID) absorb(ID fsize_yr naics3_yr)
    outreg2  using "Fig4Data.xls", keep(PostTWITExp_A0 PostTWRTExp_A0) append addtext(Firm FE, yes, Baseline Firm Size  x year, yes, naics3 x year, yes, Naics, Agriculture, US-MEX DiffT, yes)  nocons dec(3) dta noaster

reghdfe lnExportUSD PostTWITExp_A0 PostTWRTExp_A0 $TWITMex $TWRTMex if  IMM_Ref==1 & SManu==1, vce(cluster ID) absorb(ID fsize_yr naics3_yr)
	outreg2  using "Fig4Data.xls", keep(PostTWITExp_A0 PostTWRTExp_A0) append addtext(Firm FE, yes, Baseline Firm Size  x year, yes, naics3 x year, yes, Naics, Manufacturing, US-MEX DiffT, yes)  nocons dec(3) dta noaster

reghdfe lnExportUSD PostTWITExp_A0 PostTWRTExp_A0 $TWITMex $TWRTMex if  IMM_Ref==1 & naics1_ref>=4, vce(cluster ID) absorb(ID fsize_yr naics3_yr)
	outreg2  using "Fig4Data.xls", keep(PostTWITExp_A0 PostTWRTExp_A0) append addtext(Firm FE, yes, Baseline Firm Size  x year, yes, naics3 x year, yes, Naics, Services, US-MEX DiffT, yes)  nocons dec(3) dta noaster

	
reghdfe lnExportUSD PostTWITExp_A0 PostTWRTExp_A0 $TWITMex $TWRTMex if  IMM_Ref==1 & (naics2_ref==31 ), vce(cluster ID) absorb(ID fsize_yr naics3_yr)
	outreg2  using "Fig4Data.xls", keep(PostTWITExp_A0 PostTWRTExp_A0) append addtext(Firm FE, yes, Baseline Firm Size  x year, yes, naics3 x year, yes, Naics, 31, US-MEX DiffT, yes)  nocons dec(3) dta noaster
	
reghdfe lnExportUSD PostTWITExp_A0 PostTWRTExp_A0 $TWITMex $TWRTMex if  IMM_Ref==1 & naics2_ref==32, vce(cluster ID) absorb(ID fsize_yr naics3_yr)
	outreg2  using "Fig4Data.xls", keep(PostTWITExp_A0 PostTWRTExp_A0) append addtext(Firm FE, yes, Baseline Firm Size  x year, yes, naics3 x year, yes, Naics, 32, US-MEX DiffT, yes)  nocons dec(3) dta noaster

reghdfe lnExportUSD PostTWITExp_A0 PostTWRTExp_A0 $TWITMex $TWRTMex if  IMM_Ref==1 & naics2_ref==33, vce(cluster ID) absorb(ID fsize_yr naics3_yr)
	outreg2  using "Fig4Data.xls", keep(PostTWITExp_A0 PostTWRTExp_A0) append addtext(Firm FE, yes, Baseline Firm Size  x year, yes, naics3 x year, yes, Naics, 33, US-MEX DiffT, yes)  nocons dec(3) dta noaster
	
	
**Figure B.7 and Figure B.8


reghdfe lnUSAExport PostTWITExp_A0 PostTWRTExp_A0 $TWITMex $TWRTMex if  IMM_Ref==1 & (naics1_ref==1 | naics1_ref==2), vce(cluster ID) absorb(ID fsize_yr naics3_yr)
    outreg2  using "FigB7B8.xls", keep(PostTWITExp_A0 PostTWRTExp_A0) append addtext(Firm FE, yes, Baseline Firm Size  x year, yes, naics3 x year, yes, Naics, Agriculture, US-MEX DiffT, yes)  nocons dec(3) dta noaster

reghdfe lnUSAExport PostTWITExp_A0 PostTWRTExp_A0 $TWITMex $TWRTMex if  IMM_Ref==1 & SManu==1, vce(cluster ID) absorb(ID fsize_yr naics3_yr)
	outreg2  using "FigB7B8.xls", keep(PostTWITExp_A0 PostTWRTExp_A0) append addtext(Firm FE, yes, Baseline Firm Size  x year, yes, naics3 x year, yes, Naics, Manufacturing, US-MEX DiffT, yes)  nocons dec(3) dta noaster

reghdfe lnUSAExport PostTWITExp_A0 PostTWRTExp_A0 $TWITMex $TWRTMex if  IMM_Ref==1 & naics1_ref>=4, vce(cluster ID) absorb(ID fsize_yr naics3_yr)
	outreg2  using "FigB7B8.xls", keep(PostTWITExp_A0 PostTWRTExp_A0) append addtext(Firm FE, yes, Baseline Firm Size  x year, yes, naics3 x year, yes, Naics, Services, US-MEX DiffT, yes)  nocons dec(3) dta noaster

	
reghdfe lnUSAExport PostTWITExp_A0 PostTWRTExp_A0 $TWITMex $TWRTMex if  IMM_Ref==1 & (naics2_ref==31 ), vce(cluster ID) absorb(ID fsize_yr naics3_yr)
	outreg2  using "FigB7B8.xls", keep(PostTWITExp_A0 PostTWRTExp_A0) append addtext(Firm FE, yes, Baseline Firm Size  x year, yes, naics3 x year, yes, Naics, 31, US-MEX DiffT, yes)  nocons dec(3) dta noaster
	
reghdfe lnUSAExport PostTWITExp_A0 PostTWRTExp_A0 $TWITMex $TWRTMex if  IMM_Ref==1 & naics2_ref==32, vce(cluster ID) absorb(ID fsize_yr naics3_yr)
	outreg2  using "FigB7B8.xls", keep(PostTWITExp_A0 PostTWRTExp_A0) append addtext(Firm FE, yes, Baseline Firm Size  x year, yes, naics3 x year, yes, Naics, 32, US-MEX DiffT, yes)  nocons dec(3) dta noaster

reghdfe lnUSAExport PostTWITExp_A0 PostTWRTExp_A0 $TWITMex $TWRTMex if  IMM_Ref==1 & naics2_ref==33, vce(cluster ID) absorb(ID fsize_yr naics3_yr)
	outreg2  using "FigB7B8.xls", keep(PostTWITExp_A0 PostTWRTExp_A0) append addtext(Firm FE, yes, Baseline Firm Size  x year, yes, naics3 x year, yes, Naics, 33, US-MEX DiffT, yes)  nocons dec(3) dta noaster
	
**Figure 5


reghdfe lnXConsGood $TWITEXP_Coefs $TWRTExp $TWITMex $TWRTMex   if  IMM_Ref==1, vce(cluster ID) absorb(ID  year  naics1_yr fsize_yr)
est store lnxcons
outreg2  using "Fig5Data.xls", append keep($TWITEXP) addtext(Firm FE, yes, Baseline Firm Size  x year, yes, naics1 x year, yes, CNRet, Yes,USTonMex, Yes, MexRetonUS, Yes)  nocons dec(3) dta label


reghdfe lnXIntCap $TWITEXP_Coefs $TWRTExp $TWITMex $TWRTMex   if  IMM_Ref==1, vce(cluster ID) absorb(ID  year  naics1_yr fsize_yr)
est store lnxintcap
outreg2  using "Fig5Data.xls", append keep($TWITEXP) addtext(Firm FE, yes, Baseline Firm Size  x year, yes, naics1 x year, yes, CNRet, Yes,USTonMex, Yes, MexRetonUS, Yes)  nocons dec(3) dta label



reghdfe lnXRawMat $TWITEXP_Coefs $TWRTExp $TWITMex $TWRTMex   if  IMM_Ref==1, vce(cluster ID) absorb(ID  year  naics1_yr fsize_yr)
est store lnxraw
outreg2  using "Fig5Data.xls", append keep($TWITEXP) addtext(Firm FE, yes, Baseline Firm Size  x year, yes, naics1 x year, yes, CNRet, Yes,USTonMex, Yes, MexRetonUS, Yes)  nocons dec(3) dta label




coefplot (lnxcons, label("Dep. var. Log Consumer Goods Exports")  msymbol(D) msize(medium) lcolor(black) mcolor(black) ciopts(lcolor(gs5)) offset(-0.10) ) ///
(lnxintcap, label("Dep. var. Log Intermediate and Capital Goods Exports")  msymbol(O) msize(medium) lcolor(black) mcolor(black) ciopts(lcolor(gs5)) offset(0.0) )  ///
(lnxraw, label("Dep. var. Log Raw Materials Exports")  msymbol(S) msize(medium) lcolor(black) mcolor(black) ciopts(lcolor(gs5)) offset(0.10)), ///
keep($TWITEXP_Coefs ) vertical omit graphregion(fcolor(white) lcolor(white)) coeflabels(, angle(45)) yline(0,  lpattern(solid))  /// 
ytitle("Firms' Exposure to US Tariffs on China") legend(cols(1) ring(0) pos(11) size(small))  nooffset ylabel(-2 (0.5) 2.5)  
graph export "Figure5.pdf", replace	// Fig_gvc_lnxconsintcapraw.pdf
	

	*Figure B9
	
local ylist"XCons XIntCap  XRaw"

foreach y of local ylist{
	reghdfe IHS_f_`y'_HS6 $TWITEXP_Coefs $TWRTExp $TWITMex $TWRTMex   if  IMM_Ref==1, vce(cluster ID) absorb(ID  year  naics1_yr fsize_yr)
est store ihsprod`y'
outreg2  using "FigB9Data.xls", append keep($TWITEXP) addtext(Firm FE, yes, Baseline Firm Size  x year, yes, naics1 x year, yes, CNRet, Yes,USTonMex, Yes, MexRetonUS, Yes)  nocons dec(3) dta label

}

coefplot  (ihsprodXCons, label("Dep. var. IHS No. of Exported Consumer Goods")  msymbol(D) msize(medium) lcolor(olive) mcolor(olive) ciopts(lcolor(olive)) offset(-0.10) )  ///
(ihsprodXIntCap, label("Dep. var. IHS No. of Exported Intermediate and Capital Goods")  msymbol(O) msize(medium) lcolor(blue) mcolor(blue) ciopts(lcolor(blue)) offset(0.0) ) ///
(ihsprodXRaw, label("Dep. var. IHS No. of Exported Raw Materials")  msymbol(S) msize(medium) lcolor(sand) mcolor(sand) ciopts(lcolor(sand)) offset(0.10)), ///
keep($TWITEXP_Coefs ) vertical omit graphregion(fcolor(white) lcolor(white)) coeflabels(, angle(45)) yline(0,  lpattern(solid))  /// 
ytitle("Firms' Exposure to US Tariffs on China") legend(cols(1) ring(0) pos(11) size(small))  nooffset ylabel(-0.5 (0.25) 1)  
graph export "FigureB9.pdf", replace // Fig_gvc_ihshs6xconsintcapraw.pdf


	
	*Figure B10
	


reghdfe lnXLowT $TWITEXP_Coefs $TWRTExp $TWITMex $TWRTMex   if  IMM_Ref==1, vce(cluster ID) absorb(ID  year  naics1_yr fsize_yr)
est store lnlowt
outreg2  using "FigB10Data.xls", replace keep($TWITEXP) addtext(Firm FE, yes, Baseline Firm Size x year, yes, naics1 x year, yes, CNRet, Yes,USTonMex, Yes, MexRetonUS, Yes)  nocons dec(3) dta label noaster

reghdfe lnXHighMid $TWITEXP_Coefs $TWRTExp $TWITMex $TWRTMex   if  IMM_Ref==1, vce(cluster ID) absorb(ID  year  naics1_yr fsize_yr)
est store lnhighmid
outreg2  using "FigB10Data.xls", append keep($TWITEXP) addtext(Firm FE, yes, Baseline Firm Size  x year, yes, naics1 x year, yes, CNRet, Yes,USTonMex, Yes, MexRetonUS, Yes)  nocons dec(3) dta label noaster



local ylist"XHighT XMidT XLowT XHighMidT"

foreach y of local ylist{
	reghdfe IHS_f_`y'_HS6 $TWITEXP_Coefs $TWRTExp $TWITMex $TWRTMex   if  IMM_Ref==1, vce(cluster ID) absorb(ID  year  naics1_yr fsize_yr)
est store ihsprod`y'
outreg2  using "FigB10Data.xls", append keep($TWITEXP) addtext(Firm FE, yes, Baseline Firm Size  x year, yes, naics1 x year, yes, CNRet, Yes,USTonMex, Yes, MexRetonUS, Yes)  nocons dec(3) dta label noaster
}


coefplot (lnhighmid, label("Dep. var. Log High- and Mid-Tech Exports")  msymbol(Oh) msize(medium) lcolor(blue) mcolor(blue) ciopts(lcolor(blue)) ) ///
(lnlowt, label("Dep. var. Log Low-Tech Exports")  msymbol(Sh) msize(medium) lcolor(gold) mcolor(gold) ciopts(lcolor(gold)) offset(0.10)), ///
keep($TWITEXP_Coefs ) vertical omit graphregion(fcolor(white) lcolor(white)) coeflabels(, angle(45)) yline(0,  lpattern(solid))  /// 
ytitle("Firms' Exposure to US Tariffs on China") legend(cols(1) ring(0) pos(11) size(small))  nooffset ylabel(-2 (0.5) 2.5)  
graph export "FigureB10a.pdf", replace

	

coefplot (ihsprodXHighMidT, label("Dep. var. IHS # of High- and Mid-Tech Products")  msymbol(Oh) msize(medium) lcolor(blue) mcolor(blue) ciopts(lcolor(blue)) ) ///
(ihsprodXLowT, label("Dep. var. IHS # of Low-Tech Products")  msymbol(Sh) msize(medium) lcolor(gold) mcolor(gold) ciopts(lcolor(gold)) offset(0.10)), ///
keep($TWITEXP_Coefs ) vertical omit graphregion(fcolor(white) lcolor(white)) coeflabels(, angle(45)) yline(0,  lpattern(solid))  /// 
ytitle("Firms' Exposure to US Tariffs on China") legend(cols(1) ring(0) pos(11) size(small))  nooffset ylabel(-1 (0.25) 1)  
graph export "FigureB10b.pdf", replace	
	

	

**Table B.3




local text"Firm FE, YES, Baseline Firm Size  x Year, YES, NAICS1 x Year, YES, US-Mex DiffT, Yes, RetCN DiffT, Yes"


reghdfe lnXUS_DIT_IntCap PostTWITExp_A0 PostTWRTExp_A0 PostTWITExpUS_Mex PostTWRTImpUS_Mex   if  IMM_Ref==1, vce(cluster ID) absorb(ID  year  naics1_yr fsize_yr)
outreg2  using "TableB3.xls", append keep(PostTWITExp_A0) addtext(`text')   nocons dec(3) dta label symbol(^{a}, ^{b}, ^{c}) alpha(0.01, 0.05, 0.10)

reghdfe lnXUS_DIT_Cons PostTWITExp_A0 PostTWRTExp_A0 PostTWITExpUS_Mex PostTWRTImpUS_Mex   if  IMM_Ref==1, vce(cluster ID) absorb(ID  year  naics1_yr fsize_yr)
outreg2  using "TableB3.xls", append keep(PostTWITExp_A0)  addtext(`text')   nocons dec(3) dta label symbol(^{a}, ^{b}, ^{c}) alpha(0.01, 0.05, 0.10)

reghdfe lnXUS_DIT_Raw PostTWITExp_A0 PostTWRTExp_A0 PostTWITExpUS_Mex PostTWRTImpUS_Mex   if  IMM_Ref==1, vce(cluster ID) absorb(ID  year  naics1_yr fsize_yr)
outreg2  using "TableB3.xls", append keep(PostTWITExp_A0)  addtext(`text')   nocons dec(3) dta label symbol(^{a}, ^{b}, ^{c}) alpha(0.01, 0.05, 0.10)


reghdfe lnXUS_DIT15_IntCap PostTWITExp_A0 PostTWRTExp_A0 PostTWITExpUS_Mex PostTWRTImpUS_Mex   if  IMM_Ref==1, vce(cluster ID) absorb(ID  year  naics1_yr fsize_yr)
outreg2  using "TableB3.xls", append keep(PostTWITExp_A0)  addtext(`text')   nocons dec(3) dta label symbol(^{a}, ^{b}, ^{c}) alpha(0.01, 0.05, 0.10)

reghdfe lnXUS_DIT15_Cons PostTWITExp_A0 PostTWRTExp_A0 PostTWITExpUS_Mex PostTWRTImpUS_Mex   if  IMM_Ref==1, vce(cluster ID) absorb(ID  year  naics1_yr fsize_yr)
outreg2  using "TableB3.xls", append keep(PostTWITExp_A0)  addtext(`text')   nocons dec(3) dta label symbol(^{a}, ^{b}, ^{c}) alpha(0.01, 0.05, 0.10)

reghdfe lnXUS_DIT15_Raw PostTWITExp_A0 PostTWRTExp_A0 PostTWITExpUS_Mex PostTWRTImpUS_Mex   if  IMM_Ref==1, vce(cluster ID) absorb(ID  year  naics1_yr fsize_yr)
outreg2  using "TableB3.xls", append keep(PostTWITExp_A0)  addtext(`text')   nocons dec(3) dta label symbol(^{a}, ^{b}, ^{c}) alpha(0.01, 0.05, 0.10)

	
**Table B.4 new products

local ylist"new  new_tr0  new_tr5  new_tr15 "

foreach y of local ylist{

	
reghdfe IHS_`y' PostTWITExp_A0  PostTWRTExp_A0 PostTWITExpUS_Mex PostTWRTImpUS_Mex  if  IMM_Ref==1 & SManu==1, vce(cluster ID) absorb(ID  year  naics1_yr fsize_yr)
	outreg2  using "TableB4_1.xls", append keep( PostTWITExp_A0) title("Number of New Exported Goods")   nocons dec(3) dta symbol(^{a}, ^{b}, ^{c}) alpha(0.01, 0.05, 0.10)
}

local ylist"newval new_tr0_val new_tr5_val new_tr15_val"
foreach y of local ylist{

reghdfe IHS_`y' PostTWITExp_A0  PostTWRTExp_A0 PostTWITExpUS_Mex PostTWRTImpUS_Mex  if  IMM_Ref==1 & SManu==1, vce(cluster ID) absorb(ID  year  naics1_yr fsize_yr)
	outreg2  using "TableB4_2.xls", append keep( PostTWITExp_A0) title("Export Value of New Goods(ihs)")   nocons dec(3) dta symbol(^{a}, ^{b}, ^{c}) alpha(0.01, 0.05, 0.10)

}

***Figure 6

reghdfe lnUSAExport $TWITEXP_Coefs $TWRTExp $TWITMex $TWRTMex   if  IMM_Ref==1 & fparC==1, vce(cluster ID) absorb(ID  year  naics1_yr fsize_yr)
est store usx_fpC
outreg2  using "Fig6Data.xls", replace keep($TWITEXP) ctitle("Foreign") addtext("Firm FE, YES, NAICS1 x YR, YES, Baseline FSize x YR, YES")  nocons dec(3) dta label


reghdfe lnUSAExport $TWITEXP_Coefs $TWRTExp $TWITMex $TWRTMex   if  IMM_Ref==1 & MXFirmC==1, vce(cluster ID) absorb(ID  year  naics1_yr fsize_yr)
est store usx_mxfC
outreg2  using "Fig6Data.xls", append keep($TWITEXP) ctitle("Domestic") addtext("Firm FE, YES, NAICS1 x YR, YES, Baseline FSize x YR, YES")  nocons dec(3) dta label

reghdfe lnUSAExport $TWITEXP_Coefs $TWRTExp $TWITMex $TWRTMex   if  IMM_Ref==1 & USParC==1, vce(cluster ID) absorb(ID  year  naics1_yr fsize_yr)
est store usx_uspC
outreg2  using "Fig6Data.xls", append keep($TWITEXP) ctitle("US Firms") addtext("Firm FE, YES, NAICS1 x YR, YES, Baseline FSize x YR, YES")  nocons dec(3) dta label






coefplot (usx_fpC, label("Foreign MNEs")  msymbol(Oh) msize(medium) lcolor(black) mcolor(black) ciopts(lcolor(gs5)) offset(-0.10)) ///
(usx_uspC, label("US MNEs")  msymbol(S) msize(medium) lcolor(black) mcolor(black) ciopts(lcolor(gs5)) offset(0.0)) ///
(usx_mxfC, label("Domestic GVC Firms")  msymbol(Dh) msize(medium) lcolor(black) mcolor(black) ciopts(lcolor(gs5)) offset(0.10)), ///
keep($TWITEXP_Coefs ) vertical omit graphregion(fcolor(white) lcolor(white)) coeflabels(, angle(45)) yline(0,  lpattern(solid))  /// xline(3.25, lcolor(gs10)) recast(connected)
ytitle("Firms' Exposure to US Tariffs on China") legend(cols(1) ring(0) pos(11) size(small))   ylabel(-1 (0.5) 2.5)  note("Dep. Var. Log US Exports", position(11) ring(1))
graph export "Figure6.pdf", replace



	
	
**Figure 7

local text"Firm FE, YES, BaselineFS x Year, YES,  US Tariffs on Mex, YES, Mexico's Retaliatory Tariffs, YES, Exposure to China's Ret Tariffs, YES, Sample, Manu"


reghdfe lnUSAExport  $TWITEXP_Coefs $TWRTExp $TWITMex $TWRTMex   if  IMM_Ref==1 & SManu==1, vce(cluster ID) absorb(ID  year  naics1_yr fsize_yr)
est store m_lnusx
outreg2  using "Fig7Data.xls", replace keep($TWITEXP) addtext(`text')   nocons dec(3) dta label 

reghdfe lnUSAImport  $TWITEXP_Coefs $TWRTExp $TWITMex $TWRTMex   if  IMM_Ref==1 & SManu==1, vce(cluster ID) absorb(ID  year  naics1_yr fsize_yr)
est store m_lnusimp
outreg2  using "Fig7Data.xls", append keep($TWITEXP) addtext(`text')   nocons dec(3) dta label 


reghdfe lnExportUSD  $TWITEXP_Coefs $TWRTExp $TWITMex $TWRTMex   if  IMM_Ref==1 & SManu==1, vce(cluster ID) absorb(ID  year  naics1_yr fsize_yr)
est store m_lnx
outreg2  using "Fig7Data.xls", append keep($TWITEXP) addtext(`text')   nocons dec(3) dta label 

reghdfe lnImportUSD  $TWITEXP_Coefs $TWRTExp $TWITMex $TWRTMex   if  IMM_Ref==1 & SManu==1, vce(cluster ID) absorb(ID  year  naics1_yr fsize_yr)
est store m_lnimp
outreg2  using "Fig7Data.xls", append keep($TWITEXP) addtext(`text')   nocons dec(3) dta label 





coefplot (m_lnusx, label("Dep. var. Log US Exports")  msymbol(Dh) msize(medium) lcolor(black) mcolor(black) ciopts(lcolor(gs5)) offset(-0.07)) ///
(m_lnusimp, label("Dep. var. Log US Imports")  msymbol(D) msize(medium) lcolor(black) mcolor(black) ciopts(lcolor(gs5)) offset(0.07) ), ///
keep($TWITEXP_Coefs ) vertical omit graphregion(fcolor(white) lcolor(white)) coeflabels(, angle(45)) yline(0,  lpattern(solid))  /// 
ytitle("Firms' Exposure to US Tariffs on China") legend(cols(1) ring(0) pos(11) size(small)) ylabel(-0.75 (0.25) 2) nooffset 
graph export "Figure7a.pdf", replace
	
	
coefplot (m_lnx, label("Dep. var. Log Total Exports")  msymbol(Oh) msize(medium) lcolor(black) mcolor(black) ciopts(lcolor(gs5)) offset(-0.07)) ///
(m_lnimp, label("Dep. var. Log Total Imports")  msymbol(O) msize(medium) lcolor(black) mcolor(black) ciopts(lcolor(gs5)) offset(0.07) ), ///
keep($TWITEXP_Coefs ) vertical omit graphregion(fcolor(white) lcolor(white)) coeflabels(, angle(45)) yline(0,  lpattern(solid))  /// 
ytitle("Firms' Exposure to US Tariffs on China") legend(cols(1) ring(0) pos(11) size(small)) ylabel(-0.75 (0.25) 2) nooffset 
graph export "Figure7b.pdf", replace



**Figure 8
local text"Firm FE, YES, BaselineFS x Year, YES,  US Tariffs on Mex, YES, Mexico's Retaliatory Tariffs, YES, Exposure to China's Ret Tariffs, YES, Sample, Manufacturing"


local ylist"USAImport EU28Import LACImport CHNImport  OTHASImport "


foreach y of local ylist{
	
	
reghdfe ln`y' PostTWITExp_A0 PostTWRTExp_A0 PostTWITExpUS_Mex PostTWRTImpUS_Mex     if  IMM_Ref==1 & SManu==1 & USParC==1, vce(cluster ID) absorb(ID  year  naics1_yr fsize_yr)
	outreg2  using "Fig8Data_1.xls", append keep(PostTWITExp_A0) title("US MNEs") addtext(`text')  nocons dec(3) dta label

reghdfe ln`y' PostTWITExp_A0 PostTWRTExp_A0 PostTWITExpUS_Mex PostTWRTImpUS_Mex      if  IMM_Ref==1 & SManu==1 & USParC==0 & fparC==1, vce(cluster ID) absorb(ID  year  naics1_yr fsize_yr)
	outreg2  using "Fig8Data_2.xls", append keep(PostTWITExp_A0) title("Non-US Foreign MNEs") addtext(`text')  nocons dec(3) dta label
	
reghdfe ln`y' PostTWITExp_A0 PostTWRTExp_A0 PostTWITExpUS_Mex PostTWRTImpUS_Mex       if  IMM_Ref==1 & SManu==1 & MXFirmC==1, vce(cluster ID) absorb(ID  year  naics1_yr fsize_yr)
	outreg2  using "Fig8Data_3.xls", append keep(PostTWITExp_A0) title("Domesticly Owned GVCs") addtext(`text')  nocons dec(3) dta label
}



**Figure 9a

	
reghdfe PROSEC $TWITEXP_Coefs $TWRTExp $TWITMex $TWRTMex   if  IMM_Ref==1 & SManu==1 , vce(cluster ID) absorb(ID  year fsize_yr)	
	est store pros_gvc_man
outreg2  using "Fig9aData.xls", replace keep($TWITEXP) ctitle("GVCs")   nocons dec(3) dta label	

reghdfe PROSEC $TWITEXP_Coefs $TWRTExp $TWITMex $TWRTMex   if  IMM_Ref==1 & SManu==1 & fparC==1, vce(cluster ID) absorb(ID  year fsize_yr)	
	est store pros_manfgvc
outreg2  using "Fig9aData.xls", append keep($TWITEXP)  ctitle("Foreign MNEs")   nocons dec(3) dta label	

	
reghdfe PROSEC $TWITEXP_Coefs $TWRTExp $TWITMex $TWRTMex   if  IMM_Ref==1 & SManu==1 & MXFirmC==1, vce(cluster ID) absorb(ID  year fsize_yr)	
	est store pros_mandgvc
outreg2  using "Fig9aData.xls", append keep($TWITEXP)  ctitle("Dometic GVCs")   nocons dec(3) dta label		


	coefplot (pros_gvc_man, label("All Manufacturing GVC Firms")  msymbol(Dh) msize(medium) lcolor(black) mcolor(black) ciopts(lcolor(gs5)) offset(-0.10) ) ///
(pros_manfgvc, label("Foreign")  msymbol(O) msize(medium) lcolor(black) mcolor(black) ciopts(lcolor(gs5)) offset(0.0)) ///
(pros_mandgvc, label("Domestic")  msymbol(Oh) msize(medium) lcolor(black) mcolor(black) ciopts(lcolor(gs5)) offset(0.10)), ///
keep($TWITEXP_Coefs ) vertical omit graphregion(fcolor(white) lcolor(white)) coeflabels(, angle(45)) yline(0,  lpattern(solid))  /// 
ytitle("Firms' Exposure to US Tariffs on China") legend(cols(1) ring(0) pos(11) size(small))  nooffset ylabel(-0.10 (0.1) 0.60)   note("Dep. var. for all regressions: Duty Free Input (Regla Octava) Dummy")
graph export "Figure9a.pdf", replace



	
	
**Table 2
local text"Firm FE, YES, BaselineFS x Year, YES, NAICS1 x Year, YES, US Tariffs on Mex, YES, Mexico's Retaliatory Tariffs, YES, Exposure to China's Ret Tariffs, YES, Sample, Manu"


local ylist"ImportUSD USAImport EU28Import LACImport CHNImport  OTHASImport "


foreach y of local ylist{
	
	
reghdfe ln`y' $TWITEXP $TWRTExp $TWITMex $TWRTMex   if  IMM_Ref==1 & SManu==1, vce(cluster ID) absorb(ID  year  naics1_yr fsize_yr)
	outreg2  using "Table2.xls", append keep($TWITEXP) title("Sourcing Ajustments among Manufacturing GVCs") addtext(`text')  nocons dec(3) dta symbol(^{a}, ^{b}, ^{c}) alpha(0.01, 0.05, 0.10)
	


}


	


**Figure 9b



local ylist"tot98 c98_USA c98_EU28 c98_LAC c98_CHN c98_OTHAS"


foreach y of local ylist{

	
reghdfe IHS_`y' PostTWITExp_A0 PostTWRTExp_A0 $TWITMex $TWRTMex   if  IMM_Ref==1 & SManu==1, vce(cluster ID) absorb(ID  year  naics1_yr fsize_yr)
	outreg2  using "Fig9bData.xls", keep(PostTWITExp_A0) append title("Figure 9b Effect of US Tariffs on Manufacturing GVC Firms' Use of Preferential Duties") noaster  nocons dec(3) dta label

	
}




preserve

			

forval i=1/7{
use "Fig`i'Data_dta", replace
export excel `filename', sheet(Figure`i', modify) 

capture erase "Fig`i'Data_dta.dta"

capture erase "Fig`i'Data.txt"

capture erase "Fig`i'Data.xls"	
}




use "Table2_dta", replace
export excel `filename', sheet(Table2, modify)

capture erase "Table2_dta.dta"

capture erase "Table2.txt"

capture erase "Table2.xls"


use "Fig8Data_1_dta", replace
export excel `filename', sheet(Figure8, modify) cell(A1)
use "Fig8Data_2_dta", replace
export excel `filename', sheet(Figure8, modify) cell(A10)
use "Fig8Data_3_dta", replace
export excel `filename', sheet(Figure8, modify) cell(A20)

forval i=1/3{
capture erase "Fig8Data_`i'_dta.dta"
capture erase "Fig8Data_`i'.txt"
capture erase "Fig8Data_`i'.xls"
}

use "Fig9aData_dta", replace
export excel `filename', sheet(Figure9, modify) cell(A1)

use "Fig9bData_dta", replace
export excel `filename', sheet(Figure9, modify) cell(A30)

capture erase "Fig9aData_dta.dta"
capture erase "Fig9aData.txt"
capture erase "Fig9aData.xls"



capture erase "Fig9bData_dta.dta"
capture erase "Fig9bData.txt"
capture erase "Fig9bData.xls"		

restore



****Appendix Tables


**Appendix A

**Table A.1 Firms' Trade Across Destinations



global t2list "USA_xsh  CAN_xsh LAC_xsh EU28_xsh CHN_xsh OTHAS_xsh USA_msh CAN_msh LAC_msh EU28_msh CHN_msh  OTHAS_msh"

putexcel set `filename', sheet(TableA1) modify
putexcel A1=("Variable") B1=("Variable") C1=("Mean") D1=("p25") E1=("p75")  F1=("N")
local row=2
foreach var of varlist $t2list{
	qui sum `var' if  IMM_Ref==0 & year==`refyear' , d
	local varlabel: var label `var'
	qui putexcel A`row'=("`varlabel'")
		qui putexcel B`row'=("`var'")
	qui putexcel C`row'=(r(mean))
	qui putexcel D`row'=(r(p25))
	qui putexcel E`row'=(r(p75))
	qui putexcel F`row'=(r(N))

	local ++row
	
}


putexcel set `filename', sheet(TableA1) modify
putexcel G1=("Variable") H1=("Variable") I1=("Mean") J1=("p25") K1=("p75") L1=("N") 
local row=2
foreach var of varlist $t2list{
	qui sum `var' if IMM_Ref==1 & year==`refyear', d
	local varlabel: var label `var'
	qui putexcel G`row'=("`varlabel'")
		qui putexcel H`row'=("`var'")
	qui putexcel I`row'=(r(mean))
	qui putexcel J`row'=(r(p25))
	qui putexcel K`row'=(r(p75))
	qui putexcel L`row'=(r(N))

	local ++row
	
}




**Table A.2  Exposure measures



global twlist "TWITExp_A0 TWRTExp_A0 TWITExpUS_Mex TWRTImpUS_Mex "


putexcel set `filename', sheet(TableA2) modify
putexcel A1=("Variable") B1=("Variable") C1=("Mean") D1=("SD") E1=("p25") F1=("p75") G1=("Obs") 
local row=2
foreach var of varlist $twlist{
	qui sum `var' , d
	local varlabel: var label `var'
	qui putexcel A`row'=("`varlabel'")
		qui putexcel B`row'=("`var'")
	qui putexcel C`row'=(r(mean))
	qui putexcel D`row'=(r(sd))
	qui putexcel E`row'=(r(p25))
	qui putexcel F`row'=(r(p75))
	qui putexcel G`row'=(r(N))

	local ++row
	
}

putexcel set `filename', sheet(TableA2) modify
putexcel A10=("IMMEX") B10=("Variable") C10=("Mean") D10=("SD") E10=("p25") F10=("p75") G10=("Obs") 
local row=11
foreach var of varlist $twlist{
	qui sum `var' if IMM_Ref==1, d


qui putexcel A`row'=("`varlabel'")
		qui putexcel B`row'=("`var'")
	qui putexcel C`row'=(r(mean))
	qui putexcel D`row'=(r(sd))
	qui putexcel E`row'=(r(p25))
	qui putexcel F`row'=(r(p75))
	qui putexcel G`row'=(r(N))
	local ++row
	
}

**Table A.3

label define sector_lbl 1 "Agricultural and Animal Production" 2 "Mining and Utilities" 3 "Manufacturing" 4 "Warehousing and Storage Services" 5 "Business Services" 8 "Repair, Maintenance, Personal and Laundry Services" 9 "Other Services"

label values naics1_ref sector_lbl


local vlab: value label naics1_ref

putexcel set `filename', sheet(TableA3) modify

putexcel A1=("NAICS-1dig") B1=("Industry") C1=("Share") 

qui tabulate naics1_ref if IMM_Ref==1  & year==`refyear', matcell(F)

scalar T =r(N)


levelsof naics1_ref, local(xlist)

local row=2
local i 1

foreach x of local xlist{


	local lbl : label `vlab' `x'
	local pct =F[`i',1]/T
	
	qui putexcel A`row'=("`x'")
	qui putexcel B`row'="`lbl'"


	qui putexcel C`row'=`pct', nformat("0.0%")

	local ++row
	local ++i
}



**Table A.4 Summary Statistics

global vlist "PROSEC_ref  export import f_X_HS6 f_M_HS6 N_X_CO N_M_CO lnExportUSD lnImportUSD"


putexcel set `filename', sheet("TableA4") modify
putexcel A1=("Foreign MNEs") B1=("Variable") C1=("Mean") D1=("Median")  E1=("SD") F1=("Min") G1=("Max") H1=("Obs")
local row=2
foreach var of varlist $vlist{
	qui sum `var' if IMM_Ref==1 & year==`refyear' & fparC==1, d
	local varlabel: var label `var'
	qui putexcel A`row'=("`varlabel'")
		qui putexcel B`row'=("`var'")
	qui putexcel C`row'=(r(mean))
	qui putexcel D`row'=(r(p50))
	qui putexcel E`row'=(r(sd))
	qui putexcel F`row'=(r(min))
	qui putexcel G`row'=(r(max))
	qui putexcel H`row'=(r(N))
	local ++row
	
}

putexcel set `filename', sheet("TableA4") modify
putexcel A18=("Domestic IMMEX") B18=("Variable") C18=("Mean") D18=("Median")  E18=("SD") F18=("Min") G18=("Max") H18=("Obs")
local row=19
foreach var of varlist $vlist{
	qui sum `var' if IMM_Ref==1 &   year==`refyear' & MXFirmC==1, d


	qui putexcel A`row'=("`varlabel'")
	qui putexcel B`row'=("`var'")
	qui putexcel C`row'=(r(mean))
	qui putexcel D`row'=(r(p50))
	qui putexcel E`row'=(r(sd))
	qui putexcel F`row'=(r(min))
	qui putexcel G`row'=(r(max))
	qui putexcel H`row'=(r(N))
	local ++row
	
}


**Table A.5


local varlist "USA_xsh  CAN_xsh LAC_xsh EU28_xsh CHN_xsh OTHAS_xsh USA_msh CAN_msh LAC_msh EU28_msh CHN_msh  OTHAS_msh"

putexcel set `filename', sheet(TableA5) modify
putexcel A1=("ForeignParentC") B1=("Variable") C1=("Domestic") D1=("Foreign") E1=("US") F1=("EU28") G1=("OtherAsia") H1=("China")
local row=2
foreach var of local varlist{
	qui sum `var' if  year==2017 & MXFirmC==1 & IMM_Ref==1, d
	local varlabel: var label `var'
	qui putexcel A`row'=("`varlabel'")
		qui putexcel B`row'=("`var'")
	qui putexcel C`row'=(r(mean)), nformat("0.000")
	qui sum `var' if  year==2017 & fparC==1 & IMM_Ref==1, d	
qui putexcel D`row'=(r(mean)), nformat("0.000")
	qui sum `var' if  year==2017 & USParC==1 & IMM_Ref==1, d	
qui putexcel E`row'=(r(mean)), nformat("0.000")
	qui sum `var' if  year==2017 & EU28ParC==1 & IMM_Ref==1, d	
qui putexcel F`row'=(r(mean)), nformat("0.000")
	qui sum `var' if  year==2017 & OTHASParC==1 & IMM_Ref==1, d	
qui putexcel G`row'=(r(mean)), nformat("0.000")
	qui sum `var' if  year==2017 & CNParC==1 & IMM_Ref==1, d	
qui putexcel H`row'=(r(mean)), nformat("0.000")

	local ++row
	
}


**Table A.6


global twlist "TWITImpCHN_A0 TWITImpUS_A0 TWRTImpUS_A0 TWITExpUS_A0"



putexcel set `filename', sheet(TableA6) modify
putexcel A1=("Variable") B1=("Variable") C1=("Mean") D1=("SD") E1=("p25") F1=("p75") G1=("N") 
local row=2
foreach var of varlist $twlist{
	qui sum `var' , d
	local varlabel: var label `var'
	qui putexcel A`row'=("`varlabel'")
		qui putexcel B`row'=("`var'")
	qui putexcel C`row'=(r(mean))
	qui putexcel D`row'=(r(sd))
	qui putexcel E`row'=(r(p25))
	qui putexcel F`row'=(r(p75))
	qui putexcel G`row'=(r(N))

	local ++row
	
}

putexcel set `filename', sheet(TableA6) modify
	local ++row
putexcel A`row'=("IMMEX")  
	local ++row
foreach var of varlist $twlist{
	qui sum `var' if IMM_Ref==1, d
	local varlabel: var label `var'
	qui putexcel A`row'=("`varlabel'")
	qui putexcel B`row'=("`var'")
	qui putexcel C`row'=(r(mean))
	qui putexcel D`row'=(r(sd))
	qui putexcel E`row'=(r(p25))
	qui putexcel F`row'=(r(p75))
	qui putexcel G`row'=(r(N))
	
	local ++row
	
}

****Appendix Section B


local ylist"lnUSAExport lnExport"

foreach y of local ylist{

reghdfe `y' PostTWITExp_A0 PostTWRTExp_A0 , vce(cluster ID) absorb(ID  fsize_yr NonManu_yr)

outreg2  using "TableB1.xls", append keep(PostTWITExp_A0 PostTWRTExp_A0) addtext(Firm FE, Yes, Baseline Firm Size x Year FE, Yes, NonManufacturing x Year FE, Yes, Weighted, No)  nocons dec(3) dta label symbol(^{a}, ^{b}, ^{c}) alpha(0.01, 0.05, 0.10)
	

reghdfe `y' PostTWITExp_A0 PostTWRTExp_A0  PostTWITExpUS_Mex PostTWRTImpUS_Mex , vce(cluster ID) absorb(ID  fsize_yr NonManu_yr)

outreg2  using "TableB1.xls", append keep(PostTWITExp_A0 PostTWRTExp_A0) addtext(Firm FE, Yes, Baseline Firm Size x Year FE, Yes, NonManufacturing x Year FE, Yes, Weighted, No)  nocons dec(3) dta label symbol(^{a}, ^{b}, ^{c}) alpha(0.01, 0.05, 0.10)
	
	
reghdfe `y' PostTWITExp_A0 PostTWRTExp_A0 [aweight=lnxweight] , vce(cluster ID) absorb(ID  fsize_yr NonManu_yr)

outreg2  using "TableB1.xls", append keep(PostTWITExp_A0 PostTWRTExp_A0) addtext(Firm FE, Yes, Baseline Firm Size x Year FE, Yes, NonManufacturing x Year FE, Yes, Weighted, Yes)  nocons dec(3) dta label symbol(^{a}, ^{b}, ^{c}) alpha(0.01, 0.05, 0.10)
	
	
reghdfe `y' PostTWITExp_A0 PostTWRTExp_A0  PostTWITExpUS_Mex PostTWRTImpUS_Mex [aweight=lnxweight] , vce(cluster ID) absorb(ID  fsize_yr NonManu_yr)

outreg2  using "TableB1.xls", append keep(PostTWITExp_A0 PostTWRTExp_A0) addtext(Firm FE, Yes, Baseline Firm Size x Year FE, Yes, NonManufacturing x Year FE, Yes, Weighted, Yes)  nocons dec(3) dta label symbol(^{a}, ^{b}, ^{c}) alpha(0.01, 0.05, 0.10)
	
			
}



**Figure B.11 Heterogenous Responses 

reghdfe lnUSAExport  PostTWITExp_A0 PostTWRTExp_A0  PostTWITExpUS_Mex PostTWRTImpUS_Mex   if  IMM_Ref==1 & MXFirmC==1, vce(cluster ID) absorb(ID  fsize_yr naics1_yr)
outreg2  using "FigB11Data.xls", replace keep(PostTWITExp_A0) ctitle("Domestic,USExports") addtext("Firm FE, YES, NAICS1 x YR, YES, Baseline Firm Size x YR, YES")  nocons dec(3) dta label noaster

reghdfe lnUSAExport  PostTWITExp_A0 PostTWRTExp_A0  PostTWITExpUS_Mex PostTWRTImpUS_Mex   if  IMM_Ref==1 & fparC==1, vce(cluster ID) absorb(ID  fsize_yr naics1_yr)
outreg2  using "FigB11Data.xls", append keep(PostTWITExp_A0)  ctitle("Foreign,USExports") addtext("Firm FE, YES, NAICS1 x YR, YES, Baseline Firm Size x YR, YES")  nocons dec(3) dta label noaster
	
reghdfe lnUSAExport  PostTWITExp_A0 PostTWRTExp_A0  PostTWITExpUS_Mex PostTWRTImpUS_Mex   if  IMM_Ref==1 & USParC==1, vce(cluster ID) absorb(ID  fsize_yr naics1_yr)
outreg2  using "FigB11Data.xls", append keep(PostTWITExp_A0)  ctitle("US,USExports") addtext("Firm FE, YES, NAICS1 x YR, YES, Baseline Firm Size x YR, YES")  nocons dec(3) dta label noaster
		
reghdfe lnUSAExport  PostTWITExp_A0 PostTWRTExp_A0  PostTWITExpUS_Mex PostTWRTImpUS_Mex   if  IMM_Ref==1 & EU28ParC==1, vce(cluster ID) absorb(ID  fsize_yr naics1_yr)
outreg2  using "FigB11Data.xls", append keep(PostTWITExp_A0)  ctitle("EU28,USExports") addtext("Firm FE, YES, NAICS1 x YR, YES, Baseline Firm Size x YR, YES")  nocons dec(3) dta label noaster

reghdfe lnUSAExport  PostTWITExp_A0 PostTWRTExp_A0  PostTWITExpUS_Mex PostTWRTImpUS_Mex   if  IMM_Ref==1 & OTHASParC==1, vce(cluster ID) absorb(ID  fsize_yr naics1_yr)
outreg2  using "FigB11Data.xls", append keep(PostTWITExp_A0)  ctitle("OtherAsia,USExports") addtext("Firm FE, YES, NAICS1 x YR, YES, Baseline Firm Size x YR, YES")  nocons dec(3) dta label noaster
		

reghdfe lnExport  PostTWITExp_A0 PostTWRTExp_A0  PostTWITExpUS_Mex PostTWRTImpUS_Mex   if  IMM_Ref==1 & MXFirmC==1, vce(cluster ID) absorb(ID  fsize_yr naics1_yr)
outreg2  using "FigB11Data.xls", append keep(PostTWITExp_A0)  ctitle("Domestic,Exports") addtext("Firm FE, YES, NAICS1 x YR, YES, Baseline Firm Size x YR, YES")  nocons dec(3) dta label noaster

reghdfe lnExport  PostTWITExp_A0 PostTWRTExp_A0  PostTWITExpUS_Mex PostTWRTImpUS_Mex   if  IMM_Ref==1 & fparC==1, vce(cluster ID) absorb(ID  fsize_yr naics1_yr)
outreg2  using "FigB11Data.xls", append keep(PostTWITExp_A0)  ctitle("Foreign,Exports") addtext("Firm FE, YES, NAICS1 x YR, YES, Baseline Firm Size x YR, YES")  nocons dec(3) dta label noaster
	
reghdfe lnExport  PostTWITExp_A0 PostTWRTExp_A0  PostTWITExpUS_Mex PostTWRTImpUS_Mex   if  IMM_Ref==1 & USParC==1, vce(cluster ID) absorb(ID  fsize_yr naics1_yr)
outreg2  using "FigB11Data.xls", append keep(PostTWITExp_A0)  ctitle("US,Exports") addtext("Firm FE, YES, NAICS1 x YR, YES, Baseline Firm Size x YR, YES")  nocons dec(3) dta label noaster
		
reghdfe lnExport  PostTWITExp_A0 PostTWRTExp_A0  PostTWITExpUS_Mex PostTWRTImpUS_Mex   if  IMM_Ref==1 & EU28ParC==1, vce(cluster ID) absorb(ID  fsize_yr naics1_yr)
outreg2  using "FigB11Data.xls", append keep(PostTWITExp_A0)  ctitle("EU28,Exports") addtext("Firm FE, YES, NAICS1 x YR, YES, Baseline Firm Size x YR, YES")  nocons dec(3) dta label noaster

reghdfe lnExport  PostTWITExp_A0 PostTWRTExp_A0  PostTWITExpUS_Mex PostTWRTImpUS_Mex   if  IMM_Ref==1 & OTHASParC==1, vce(cluster ID) absorb(ID  fsize_yr naics1_yr)
outreg2  using "FigB11Data.xls", append keep(PostTWITExp_A0)  ctitle("OtherAsia,Exports") addtext("Firm FE, YES, NAICS1 x YR, YES, Baseline Firm Size x YR, YES")  nocons dec(3) dta label noaster


**Figure B12

reghdfe lnUSAExport  PostTWITExp_A0 PostTWRTExp_A0  PostTWITExpUS_Mex PostTWRTImpUS_Mex   if  IMM_Ref==1 & CNParC==1, vce(cluster ID) absorb(ID  fsize_yr naics1_yr)
outreg2  using "FigB12Data.xls", replace keep(PostTWITExp_A0)  ctitle("Chinese,USExports") addtext("Firm FE, YES, NAICS1 x YR, YES, Baseline Firm Size x YR, YES")  nocons dec(3) dta label noaster
		

reghdfe lnExport  PostTWITExp_A0 PostTWRTExp_A0  PostTWITExpUS_Mex PostTWRTImpUS_Mex   if  IMM_Ref==1 & CNParC==1, vce(cluster ID) absorb(ID  fsize_yr naics1_yr)
outreg2  using "FigB12Data.xls", append keep(PostTWITExp_A0)  ctitle("Chinese,Exports") addtext("Firm FE, YES, NAICS1 x YR, YES, Baseline Firm Size x YR, YES")  nocons dec(3) dta label noaster

**Figure B13


reghdfe lnUSAExport  $TWITEXP_Coefs $TWRTExp $TWITMex $TWRTMex   if  IMM_Ref==1 & SManu==1, vce(cluster ID) absorb(ID  year  naics3_yr fsize_yr)
est store m_lnusx_3dig

reghdfe lnExportUSD  $TWITEXP_Coefs $TWRTExp $TWITMex $TWRTMex   if  IMM_Ref==1 & SManu==1, vce(cluster ID) absorb(ID  year  naics3_yr fsize_yr)
est store m_lnx_3dig

reghdfe lnImportUSD  $TWITEXP_Coefs $TWRTExp $TWITMex $TWRTMex   if  IMM_Ref==1 & SManu==1, vce(cluster ID) absorb(ID  year  naics3_yr fsize_yr)
est store m_lnimp_3dig

reghdfe lnUSAImport  $TWITEXP_Coefs $TWRTExp $TWITMex $TWRTMex   if  IMM_Ref==1 & SManu==1, vce(cluster ID) absorb(ID  year  naics3_yr fsize_yr)
est store m_lnusimp_3dig


coefplot (m_lnx_3dig, label("Dep. var. Log Total Exports")  msymbol(Oh) msize(medium) lcolor(blue) mcolor(blue) ciopts(lcolor(blue)) offset(-0.07)) ///
(m_lnimp_3dig, label("Dep. var. Log Total Imports")  msymbol(O) msize(medium) lcolor(blue) mcolor(blue) ciopts(lcolor(blue)) offset(0.07) ), ///
keep($TWITEXP_Coefs ) vertical omit graphregion(fcolor(white) lcolor(white)) coeflabels(, angle(45)) yline(0,  lpattern(solid))  /// xline(3.25, lcolor(gs10)) recast(connected)
ytitle("Firms' Exposure to US Tariffs on China") legend(cols(1) ring(0) pos(11) size(small)) ylabel(-0.75 (0.25) 2) nooffset 
graph export "FigureB13b.pdf", replace

coefplot (m_lnusx_3dig, label("Dep. var. Log US Exports")  msymbol(Dh) msize(medium) lcolor(blue) mcolor(blue) ciopts(lcolor(blue)) offset(-0.07)) ///
(m_lnusimp_3dig, label("Dep. var. Log US Imports")  msymbol(D) msize(medium) lcolor(blue) mcolor(blue) ciopts(lcolor(blue)) offset(0.07) ), ///
keep($TWITEXP_Coefs ) vertical omit graphregion(fcolor(white) lcolor(white)) coeflabels(, angle(45)) yline(0,  lpattern(solid))  /// xline(3.25, lcolor(gs10)) recast(connected)
ytitle("Firms' Exposure to US Tariffs on China") legend(cols(1) ring(0) pos(11) size(small)) ylabel(-0.75 (0.25) 2) nooffset 
graph export "FigureB13a.pdf", replace


**Table B5 Heterogenous Impact of the New US Tariffs ..

local ylist"Export USAExport ImportUSD USAImport EU28Import LACImport CHNImport  OTHASImport "


foreach y of local ylist{



	
	
reghdfe ln`y' PostTWITExp_A0 PostTWRTExp_A0 PostTWITExpUS_Mex PostTWRTImpUS_Mex   if  IMM_Ref==1 & USParC==1 & SManu==1, vce(cluster ID) absorb(ID  fsize_yr)
	outreg2  using "TableB5_1.xls", keep(PostTWITExp_A0) append title("US")   nocons dec(3) dta symbol(^{a}, ^{b}, ^{c}) alpha(0.01, 0.05, 0.10)
	
	
	
reghdfe ln`y' PostTWITExp_A0 PostTWRTExp_A0 PostTWITExpUS_Mex PostTWRTImpUS_Mex   if  IMM_Ref==1 & USParC==0 & fparC==1 & SManu==1	, vce(cluster ID) absorb(ID  fsize_yr)
	outreg2  using "TableB5_2.xls", keep(PostTWITExp_A0)  append  title("NonUS") addtext(China's Ret Tariff Exp, Yes, US Tariffs on Mexico Exposure, Yes, Mexico's Ret. Tariff Exp, Yes, Baseline Firm Size x Year, Yes, Firm FE, Yes)  nocons dec(3) dta symbol(^{a}, ^{b}, ^{c}) alpha(0.01, 0.05, 0.10)
	
	
	
reghdfe ln`y' PostTWITExp_A0 PostTWRTExp_A0 PostTWITExpUS_Mex PostTWRTImpUS_Mex   if  IMM_Ref==1 & MXFirmC==1 & SManu==1, vce(cluster ID) absorb(ID  fsize_yr)
	outreg2  using "TableB5_3.xls", keep(PostTWITExp_A0)  append  title("Domestic")   nocons dec(3) dta symbol(^{a}, ^{b}, ^{c}) alpha(0.01, 0.05, 0.10)
	


	

}


**Table B.6



global shortnonusfor"  "


local ylist"tot98 c98_USA c98_EU28 c98_LAC c98_CHN c98_OTHAS"


foreach y of local ylist{



	
reghdfe IHS_`y'  PostTWITExp_A0  PostUSParCTWITExp_A0 PostnonUSForTWITExp_A0 PostnonUSFor PostUSParC  PostTWRTExp_A0 PostTWITExpUS_Mex PostTWRTImpUS_Mex if  IMM_Ref==1  & SManu==1, vce(cluster ID) absorb(ID  fsize_yr naics3_yr)
	outreg2  using "TableB6.xls", keep(PostTWITExp_A0  PostUSParCTWITExp_A0 PostnonUSForTWITExp_A0) append    nocons dec(3) dta symbol(^{a}, ^{b}, ^{c}) alpha(0.01, 0.05, 0.10)
	
	
	
}
	

**Figure B.14

	
reghdfe PROSEC $TWITEXP $TWRTExp $TWITMex $TWRTMex_Coefs  if  IMM_Ref==1 & SManu==1, vce(cluster ID) absorb(ID  year fsize_yr naics1_yr)	
	est store pros_mangvc
	
reghdfe IHS_c98_USA $TWITEXP $TWRTExp $TWITMex $TWRTMex_Coefs   if  IMM_Ref==1 & SManu==1, vce(cluster ID) absorb(ID  year fsize_yr naics1_yr)	
	est store mangvc_specUS

	
coefplot (pros_mangvc, label("Dep. var. Duty Free Input Permit (Regla Octava) Dummy")  msymbol(O) msize(medium) lcolor(blue) mcolor(blue) ciopts(lcolor(blue)) ), ///
keep($TWRTMex_Coefs) vertical omit graphregion(fcolor(white) lcolor(white)) coeflabels(, angle(45)) yline(0,  lpattern(solid))  /// 
ytitle("Firms' Exposure to Mexico's Retaliatory Tariffs") legend(cols(1) ring(0) pos(11) size(small))  nooffset ylabel(-0.5 (0.2) 1.5)  recast(connected)
graph export "FigureB14a.pdf", replace




coefplot (mangvc_specUS, label("Dep. var. (ihs) US Imports under Regla Octava")  msymbol(Oh) msize(medium) lcolor(blue) mcolor(blue) ciopts(lcolor(blue)) ), ///
keep($TWRTMex_Coefs) vertical omit graphregion(fcolor(white) lcolor(white)) coeflabels(, angle(45)) yline(0,  lpattern(solid))  /// xline(3.25, lcolor(gs10)) recast(connected)
ytitle("Firms' Exposure to Mexico's Retaliatory Tariffs") legend(cols(1) ring(0) pos(11) size(small))  nooffset ylabel(-5 (2) 22)  recast(connected)
graph export "FigureB14b.pdf", replace



**Figure B.15


cap drop aux
gen aux=0
replace aux=1 if lnExportUSD>=14.401 & year==2017
bysort ID: egen Big=max(aux)

local begdate 2015 
local enddate 2021  

local vlist "TWITExp_A0  TWRTExp_A0  TWITExpUS_Mex TWRTImpUS_Mex"
foreach v of local vlist{
			forval i=`begdate'(1)`enddate'{
	gen Big_`v'_`i'=0
	replace Big_`v'_`i'=Big*`v' if year==`i'
}
}

gen Big_yr=Big*year



forval i=`begdate'(1)`enddate'{
		gen Big_`i'=0
	replace Big_`i'=Big if year==`i'

	}

	
local twlist"TWITExp_A0 TWRTExp_A0 TWITExpUS_Mex TWRTImpUS_Mex "

foreach tw of local twlist {
		forval i=`begdate'(1)`enddate'{
	label var Big_`tw'_`i' "`i'"
}
}


global Big_TWITEXP"Big_TWITExp_A0_2015 Big_TWITExp_A0_2016 Big_TWITExp_A0_2018 Big_TWITExp_A0_2019 Big_TWITExp_A0_2020 Big_TWITExp_A0_2021"
global Big_TWRTExp"Big_TWRTExp_A0_2015 Big_TWRTExp_A0_2016  Big_TWRTExp_A0_2018 Big_TWRTExp_A0_2019 Big_TWRTExp_A0_2020 Big_TWRTExp_A0_2021"
global Big_TWITMex"Big_TWITExpUS_Mex_2015 Big_TWITExpUS_Mex_2016   Big_TWITExpUS_Mex_2018 Big_TWITExpUS_Mex_2019 Big_TWITExpUS_Mex_2020 Big_TWITExpUS_Mex_2021"
global Big_TWRTMex"Big_TWRTImpUS_Mex_2015 Big_TWRTImpUS_Mex_2016   Big_TWRTImpUS_Mex_2018 Big_TWRTImpUS_Mex_2019 Big_TWRTImpUS_Mex_2020 Big_TWRTImpUS_Mex_2021"


global Big_TWITEXP_Coefs"Big_TWITExp_A0_2015 Big_TWITExp_A0_2016 ref Big_TWITExp_A0_2018 Big_TWITExp_A0_2019 Big_TWITExp_A0_2020 Big_TWITExp_A0_2021"
global Big_TWRTExp_Coefs"Big_TWRTExp_A0_2015 Big_TWRTExp_A0_2016 ref Big_TWRTExp_A0_2018 Big_TWRTExp_A0_2019 Big_TWRTExp_A0_2020 Big_TWRTExp_A0_2021"
global Big_TWITMex_Coefs"Big_TWITExpUS_Mex_2015 Big_TWITExpUS_Mex_2016 ref  Big_TWITExpUS_Mex_2018 Big_TWITExpUS_Mex_2019 Big_TWITExpUS_Mex_2020 Big_TWITExpUS_Mex_2021"
global Big_TWRTMex_Coefs"Big_TWRTImpUS_Mex_2015 Big_TWRTImpUS_Mex_2016 ref  Big_TWRTImpUS_Mex_2018 Big_TWRTImpUS_Mex_2019 Big_TWRTImpUS_Mex_2020 Big_TWRTImpUS_Mex_2021"

reghdfe lnUSAExport  $TWITEXP_Coefs $Big_TWITEXP $TWRTExp $Big_TWRTExp $TWITMex $Big_TWITMex $TWRTMex $Big_TWRTMex [aweight=lnxweight], vce(cluster ID) absorb(ID  NonManu_yr  Big_yr fsize_yr )
est store usxb1

reghdfe lnUSAExport  $TWITEXP $Big_TWITEXP_Coefs $TWRTExp $Big_TWRTExp $TWITMex $Big_TWITMex $TWRTMex $Big_TWRTMex [aweight=lnxweight], vce(cluster ID) absorb(ID  NonManu_yr  Big_yr fsize_yr )
est store usxb2


coefplot (usxb2, label("Dep. Var. Log US Exports")   msymbol(Oh) msize(medium)  lcolor(navy) mcolor(navy) ciopts(lcolor(navy))), ///
keep($Big_TWITEXP_Coefs) vertical omit graphregion(fcolor(white) lcolor(white)) coeflabels(, angle(45)) yline(0,  lpattern(solid))  ///
ytitle("Disproportionate Impact on Fake IMMEX""DDD Coefficients") legend(cols(1) ring(0) pos(10) size(small)) ylabel(-0.75 (0.25) 2.25) 

graph export "FigureB15b.pdf", replace


coefplot (usxb1, label("Dep. Var. Log US Exports") msymbol(Sh)  msize(medium) lcolor(navy) mcolor(navy) ciopts(lcolor(navy))), ///
keep($TWITEXP_Coefs) vertical omit graphregion(fcolor(white) lcolor(white)) coeflabels(, angle(45)) yline(0,  lpattern(solid))  ///
ytitle("Common Impact""DD Coefficients") legend(cols(1) ring(0) pos(10) size(small)) ylabel(-0.75 (0.25) 2.25) 

graph export "FigureB15a.pdf", replace



**Figure B.16



reghdfe lnUSAExport  $TWITEXP_Coefs  $TWRTExp $TWITMex  $TWRTMex if IMM_Ref==1, vce(cluster ID) absorb(ID  NonManu_yr  fsize_yr )
est store usx_gvc

reghdfe lnUSAExport  $TWITEXP_Coefs  $TWRTExp $TWITMex  $TWRTMex if Big==1, vce(cluster ID) absorb(ID  NonManu_yr  fsize_yr )
est store usx_fake


coefplot (usx_gvc, label("IMMEX (N=36,347)")  msymbol(Oh) msize(medium)  lcolor(blue) mcolor(blue) ciopts(lcolor(blue)) offset(-0.05)) ///
(usx_fake, label("fake IMMEX based on firm size (N=36,757)") msymbol(Sh)  msize(medium) lcolor(navy) mcolor(navy) ciopts(lcolor(navy)) offset(0.05)), ///
keep($TWITEXP_Coefs) vertical omit graphregion(fcolor(white) lcolor(white)) coeflabels(, angle(45)) yline(0,  lpattern(solid))  /// 
ytitle("Firms' Exposure to US Tariffs on China") legend(cols(1) ring(0) pos(10) size(small)) ylabel(-0.75 (0.25) 2.25)   note("Dep. Var. Log US Exports", position(11) ring(1))

graph export "FigureB16.pdf", replace



**Figure C.1



global TWITEXPUS"TWITExpUS_A0_2015 TWITExpUS_A0_2016  TWITExpUS_A0_2018 TWITExpUS_A0_2019 TWITExpUS_A0_2020 TWITExpUS_A0_2021"
global TWRTExpUS"TWRTExpUS_A0_2015 TWRTExpUS_A0_2016 TWRTExpUS_A0_2018 TWRTExpUS_A0_2019 TWRTExpUS_A0_2020 TWRTExpUS_A0_2021"


global IMM_TWITEXPUS"IMM_TWITExpUS_A0_2015 IMM_TWITExpUS_A0_2016  IMM_TWITExpUS_A0_2018 IMM_TWITExpUS_A0_2019 IMM_TWITExpUS_A0_2020 IMM_TWITExpUS_A0_2021"
global IMM_TWRTExpUS"IMM_TWRTExpUS_A0_2015 IMM_TWRTExpUS_A0_2016 IMM_TWRTExpUS_A0_2018 IMM_TWRTExpUS_A0_2019 IMM_TWRTExpUS_A0_2020 IMM_TWRTExpUS_A0_2021"


global TWITEXPUS_Coefs"TWITExpUS_A0_2015 TWITExpUS_A0_2016 ref TWITExpUS_A0_2018 TWITExpUS_A0_2019 TWITExpUS_A0_2020 TWITExpUS_A0_2021"
global TWRTExpUS_Coefs"TWRTExpUS_A0_2015 TWRTExpUS_A0_2016 ref TWRTExpUS_A0_2018 TWRTExpUS_A0_2019 TWRTExpUS_A0_2020 TWRTExpUS_A0_2021"


global IMM_TWITEXPUS_Coefs"IMM_TWITExpUS_A0_2015 IMM_TWITExpUS_A0_2016 ref IMM_TWITExpUS_A0_2018 IMM_TWITExpUS_A0_2019 IMM_TWITExpUS_A0_2020 IMM_TWITExpUS_A0_2021"
global IMM_TWRTExpUS_Coefs"IMM_TWRTExpUS_A0_2015 IMM_TWRTExpUS_A0_2016 ref IMM_TWRTExpUS_A0_2018 IMM_TWRTExpUS_A0_2019 IMM_TWRTExpUS_A0_2020 IMM_TWRTExpUS_A0_2021"





reghdfe lnExportUSD  $TWITEXPUS_Coefs $IMM_TWITEXPUS $TWRTExpUS $IMM_TWRTExpUS $TWITMex $IMM_TWITMex $TWRTMex $IMM_TWRTMex [aweight=lnxweight], vce(cluster ID) absorb(ID   NonManu_yr IMM_Ref_yr fsize_yr )
est store x

reghdfe lnUSAExport  $TWITEXPUS_Coefs $IMM_TWITEXPUS $TWRTExpUS $IMM_TWRTExpUS $TWITMex $IMM_TWITMex $TWRTMex $IMM_TWRTMex [aweight=lnxweight], vce(cluster ID) absorb(ID  NonManu_yr  IMM_Ref_yr fsize_yr )
est store usx


coefplot (x, label("Dep. Var. Log Worldwide Exports")  msymbol(Oh) msize(medium)  lcolor(navy) mcolor(navy) ciopts(lcolor(navy)) offset(-0.05)) ///
(usx, label("Dep. Var. Log US Exports") msymbol(Sh)  msize(medium) lcolor(blue) mcolor(blue) ciopts(lcolor(blue)) offset(0.05)), ///
keep($TWITEXPUS_Coefs) vertical omit graphregion(fcolor(white) lcolor(white)) coeflabels(, angle(45)) yline(0,  lpattern(solid))  /// 
ytitle("Firms' Exposure to US Tariffs on China""Common Effect (DD)") legend(cols(1) ring(0) pos(10) size(small)) ylabel(-0.75 (0.25) 2.25) 
graph export "FigureC1a.pdf", replace



reghdfe lnExportUSD  $TWITEXPUS $IMM_TWITEXPUS_Coefs $TWRTExpUS $IMM_TWRTExpUS $TWITMex $IMM_TWITMex $TWRTMex $IMM_TWRTMex [aweight=lnxweight], vce(cluster ID) absorb(ID  year NonManu_yr IMM_Ref_yr fsize_yr )
est store x

reghdfe lnUSAExport  $TWITEXPUS $IMM_TWITEXPUS_Coefs $TWRTExpUS $IMM_TWRTExpUS $TWITMex $IMM_TWITMex $TWRTMex $IMM_TWRTMex [aweight=lnxweight], vce(cluster ID) absorb(ID  year NonManu_yr IMM_Ref_yr fsize_yr )
est store usx

coefplot (x, label("Dep. Var. Log Worldwide Exports")   msymbol(Oh) msize(medium)  lcolor(navy) mcolor(navy) ciopts(lcolor(navy)) offset(-0.05)) ///
(usx, label("Dep. Var. Log US Exports") msymbol(Sh)  msize(medium) lcolor(blue) mcolor(blue) ciopts(lcolor(blue)) offset(0.05)), ///
keep($IMM_TWITEXPUS_Coefs) vertical omit graphregion(fcolor(white) lcolor(white)) coeflabels(, angle(45)) yline(0,  lpattern(solid))  /// 
ytitle("Disproportionate Impact on GVCs""DDD Coefs") legend(cols(1) ring(0) pos(10) size(small)) ylabel(-0.75 (0.25) 2.25) 
graph export "FigureC1b.pdf", replace




**Figure C.2


reghdfe lnUSAExport $TWITEXP_Coefs $TWRTExp $TWITMex $TWRTMex [aweight=lnxweight], vce(cluster ID) absorb(ID  year NonManu_yr  fsize_yr )
est store usx_all_w




reghdfe lnUSAExport $TWITEXP_Coefs $TWRTExp $TWITMex $TWRTMex $TWITImpCHN $TWRTImpUS $TWITImpUS [aweight=lnxweight], vce(cluster ID) absorb(ID  year NonManu_yr  fsize_yr )
est store usx_all_w_ic




coefplot (usx_all_w, label("Baseline")  msymbol(Oh) msize(medium) lcolor(navy) mcolor(navy) ciopts(lcolor(navy)) offset(-0.05)) ///
(usx_all_w_ic, label("w/ Input Channel Controls") msymbol(Sh) msize(medium) lcolor(blue) mcolor(blue) ciopts(lcolor(blue)) offset(0.05)), ///
keep($TWITEXP_Coefs) vertical omit graphregion(fcolor(white) lcolor(white)) coeflabels(, angle(45)) yline(0,  lpattern(solid))  /// 
ytitle("Firms' Exposure to US Tariffs on China") legend(cols(1) ring(0) pos(11) size(small)) ylabel(-0.5 (0.25) 1.25) note("Dep. Var. Log US Exports", position(1) ring(0))
graph export "FigureC2.pdf", replace



**Figure C.3


reghdfe lnUSAExport  $TWITEXP_Coefs $IMM_TWITEXP $TWRTExp $IMM_TWRTExp $TWITMex $IMM_TWITMex $TWRTMex $IMM_TWRTMex [aweight=lnxweight], vce(cluster ID) absorb(ID  NonManu_yr  IMM_Ref_yr fsize_yr )
est store usx_w

reghdfe lnUSAExport  $TWITEXP_Coefs $IMM_TWITEXP $TWRTExp $IMM_TWRTExp $TWITMex $IMM_TWITMex $TWRTMex $IMM_TWRTMex $TWITImpCHN $IMM_TWITImpCHN $TWRTImpUS $IMM_TWRTImpUS $TWITImpUS $IMM_TWITImpUS [aweight=lnxweigh],vce(cluster ID) absorb(ID  NonManu_yr  IMM_Ref_yr fsize_yr )
est store usx_w_ic


coefplot (usx_w, label("Baseline")  msymbol(Oh) msize(medium)  lcolor(navy) mcolor(navy) ciopts(lcolor(navy)) offset(-0.05)) ///
(usx_w_ic, label("w/ Input Channel Controls") msymbol(Sh)  msize(medium) lcolor(blue) mcolor(blue) ciopts(lcolor(blue)) offset(0.05)), ///
keep($TWITEXP_Coefs) vertical omit graphregion(fcolor(white) lcolor(white)) coeflabels(, angle(45)) yline(0,  lpattern(solid))  /// 
ytitle("Firms' Exposure to US Tariffs on China""Common Effect (DD)") legend(cols(1) ring(0) pos(11) size(small)) ylabel(-0.75 (0.25) 2.25) note("Dep. Var. Log US Exports", position(11) ring(0))
graph export "FigureC3a.pdf", replace




reghdfe lnUSAExport  $TWITEXP $IMM_TWITEXP_Coefs $TWRTExp $IMM_TWRTExp $TWITMex $IMM_TWITMex $TWRTMex $IMM_TWRTMex $TWITImpCHN $IMM_TWITImpCHN $TWRTImpUS $IMM_TWRTImpUS $TWITImpUS $IMM_TWITImpUS [aweight=lnxweight], vce(cluster ID) absorb(ID  year NonManu_yr IMM_Ref_yr fsize_yr )
est store usx_w_ic


reghdfe lnUSAExport  $TWITEXP $IMM_TWITEXP_Coefs $TWRTExp $IMM_TWRTExp $TWITMex $IMM_TWITMex $TWRTMex $IMM_TWRTMex  [aweight=lnxweight], vce(cluster ID) absorb(ID  year NonManu_yr IMM_Ref_yr fsize_yr )
est store usx_w




coefplot (usx_w, label("Baseline")   msymbol(Oh) msize(medium)  lcolor(navy) mcolor(navy)  ciopts(lcolor(navy)) offset(-0.05)) ///
(usx_w_ic, label("w/ Input Channel Controls") msymbol(Sh)  msize(medium) lcolor(blue) mcolor(blue) ciopts(lcolor(blue)) offset(0.05)), ///
keep($IMM_TWITEXP_Coefs) vertical omit graphregion(fcolor(white) lcolor(white)) coeflabels(, angle(45)) yline(0,  lpattern(solid))  /// 
ytitle("Disproportionate Impact on GVCs""DDD Coefs") legend(cols(1) ring(0) pos(10) size(small)) ylabel(-0.75 (0.25) 2.25) note("Dep. Var. Log US Exports", position(11) ring(0)) 
graph export "FigureC3b.pdf", replace





**Figure D.1


sort munid_ref 

merge n:1 munid_ref using "Data Construction/Supplementary Data/BorderMun.dta"
drop if _merge==2

replace BorderMun=0 if _merge==1 & IMM_Ref==1
drop _merge



reghdfe lnUSAExport $TWITEXP_Coefs $TWRTExp $TWITMex $TWRTMex if IMM_Ref==1 & BorderMun==1, vce(cluster ID) absorb(ID  year  naics1_yr fsize_yr)
est store border_usx
outreg2  using "FigD1Data.xls", replace ctitle("Border") keep($TWITEXP) addtext("Firm FE, YES,  NAICS1 x Year, YES,   Baseline Firm Size x YR, YES, Other Trade Policy Cont, YES, Border, Yes") nocons dec(3) dta label


reghdfe lnUSAExport $TWITEXP_Coefs $TWRTExp $TWITMex $TWRTMex if IMM_Ref==1 & BorderMun!=1, vce(cluster ID) absorb(ID  year  naics1_yr fsize_yr)
est store noborder_usx
	outreg2  using "FigD1Data.xls", append ctitle("Rest") keep($TWITEXP) addtext("Firm FE, YES,  NAICS1 x Year, YES,   Baseline Firm Size x YR, YES, Other Trade Policy Cont, YES, Border, No") nocons dec(3) dta label
	


coefplot (border_usx, label("IMMEX firms in the border region")   msymbol(Oh) msize(medium) lcolor(olive) mcolor(olive) ciopts(lcolor(olive)) offset(-0.07) ) ///
(noborder_usx, label("IMMEX firms in the rest of the country") msymbol(Dh) msize(medium) lcolor(blue) mcolor(blue) ciopts(lcolor(blue)) offset(0.07) ),  ///
keep($TWITEXP_Coefs ) vertical omit graphregion(fcolor(white) lcolor(white)) coeflabels(, angle(45)) yline(0,  lpattern(solid))  /// 
ytitle("Firms' Exposure to US Tariffs on China") legend(cols(1) ring(0) pos(11) size(small))  nooffset ylabel(-1.5 (0.5) 2.25)  note("Dep. Var. Log US Exports", position(11) ring(1))
graph export "FigureD1.pdf", replace




**Figure D.2


egen munyr=group(munid_ref year)



local xlist"sib17 multip17 multip17_mun multip17_st"
foreach x of local xlist{
	gen a`x'=`x' if year==2017
	bysort ID: egen b`x'=max(a`x')
	replace `x'=b`x' if `x'==. & b`x'!=.
	drop a`x' b`x'
}

reghdfe lnUSAExport $TWITEXP_Coefs $TWRTExp $TWITMex $TWRTMex if IMM_Ref==1, vce(cluster ID) absorb(ID  year  naics1_yr fsize_yr)
est store baseline_usx
outreg2  using "FigD2Data.xls", replace keep($TWITEXP) addtext("baseline, yes")  nocons dec(3) dta label



reghdfe lnUSAExport $TWITEXP_Coefs $TWRTExp $TWITMex $TWRTMex if IMM_Ref==1, vce(cluster ID) absorb(ID  year  naics1_yr fsize_yr munyr )
est store munyr_usx
outreg2  using "FigD2Data.xls", append keep($TWITEXP) addtext("Municipality x year FE, yes")  nocons dec(3) dta label


reghdfe lnUSAExport $TWITEXP_Coefs $TWRTExp $TWITMex $TWRTMex if IMM_Ref==1 & multip17_mun==1, vce(cluster ID) absorb(ID  year  naics1_yr fsize_yr munyr )
est store munyr2_usx
outreg2  using "FigD2Data.xls", append keep($TWITEXP) addtext("Municipality x year FE, yes, Sample, Single municipality firms")  nocons dec(3) dta label



coefplot (baseline_usx, label("Baseline")  msymbol(D) msize(medium) lcolor(olive) mcolor(olive) ciopts(lcolor(olive)) offset(-0.07) ) ///
(munyr_usx, label("+ w/ Municipality x Year FEs")  msymbol(O) msize(medium) lcolor(blue) mcolor(blue) ciopts(lcolor(blue)) offset(0.0) )  ///
(munyr2_usx, label("+ w/ Municipality x Year FEs, excludes multi-municipality firms")  msymbol(Oh) msize(medium) lcolor(navy) mcolor(navy) ciopts(lcolor(navy)) offset(0.07) ),  ///
keep($TWITEXP_Coefs ) vertical omit graphregion(fcolor(white) lcolor(white)) coeflabels(, angle(45)) yline(0,  lpattern(solid))  /// 
ytitle("Firms' Exposure to US Tariffs on China") legend(cols(1) ring(0) pos(11) size(small))  nooffset ylabel(-1.5 (0.5) 2.25) note("Dep. Var. Log US Exports", position(11) ring(1))
graph export "FigureD2a.pdf", replace


reghdfe lnExportUSD $TWITEXP_Coefs $TWRTExp $TWITMex $TWRTMex if IMM_Ref==1, vce(cluster ID) absorb(ID  year  naics1_yr fsize_yr)
est store baseline_x
outreg2  using "FigD2Data.xls", append keep($TWITEXP) addtext("baseline, yes")  nocons dec(3) dta label


reghdfe lnExportUSD $TWITEXP_Coefs $TWRTExp $TWITMex $TWRTMex if IMM_Ref==1, vce(cluster ID) absorb(ID  year  naics1_yr fsize_yr munyr )
est store munyr_x
outreg2  using "FigD2Data.xls", append keep($TWITEXP) addtext("Municipality x year FE, yes")  nocons dec(3) dta label


reghdfe lnExportUSD $TWITEXP_Coefs $TWRTExp $TWITMex $TWRTMex if IMM_Ref==1 & multip17_mun==1, vce(cluster ID) absorb(ID  year  naics1_yr fsize_yr munyr )
est store munyr2_x
outreg2  using "FigD2Data.xls", append keep($TWITEXP) addtext("Municipality x year FE, yes, Sample, Single municipality firms")  nocons dec(3) dta label


coefplot (baseline_x, label("Baseline")  msymbol(D) msize(medium) lcolor(olive) mcolor(olive) ciopts(lcolor(olive)) offset(-0.07) ) ///
(munyr_x, label("+ w/ Municipality x Year FEs")  msymbol(O) msize(medium) lcolor(blue) mcolor(blue) ciopts(lcolor(blue)) offset(0.0) )  ///
(munyr2_x, label("+ w/ Municipality x Year FEs, excludes multi-municipality firms")  msymbol(Oh) msize(medium) lcolor(navy) mcolor(navy) ciopts(lcolor(navy)) offset(0.07) ),  ///
keep($TWITEXP_Coefs ) vertical omit graphregion(fcolor(white) lcolor(white)) coeflabels(, angle(45)) yline(0,  lpattern(solid))  /// 
ytitle("Firms' Exposure to US Tariffs on China") legend(cols(1) ring(0) pos(11) size(small))  nooffset ylabel(-1.5 (0.5) 2.25) note("Dep. Var. Log Exports", position(11) ring(1))
graph export "FigureD2b.pdf", replace




**Figure D.3



reghdfe lnUSAExport $TWITEXP_Coefs $TWRTExp $TWITMex $TWRTMex if IMM_Ref==1, vce(cluster ID) absorb(ID  year  naics1_yr fsize_yr)
est store baseline

reghdfe lnUSAExport $TWITEXP_Coefs $TWRTExp $TWITMex $TWRTMex if IMM_Ref==1 & SManu==1, vce(cluster ID) absorb(ID  year naics1_yr   fsize_yr)
est store manu

reghdfe lnUSAExport $TWITEXP_Coefs $TWRTExp $TWITMex $TWRTMex if IMM_Ref==1 & SManu==1 & naics3_ref!=336, vce(cluster ID) absorb(ID  year naics1_yr  fsize_yr)
est store manu_noAuto


reghdfe lnUSAExport $TWITEXP_Coefs $TWRTExp $TWITMex $TWRTMex if IMM_Ref==1 & SManu==1 & naics3_ref!=336 & naics3_ref!=313 & naics3_ref!=315, vce(cluster ID) absorb(ID  year naics1_yr  fsize_yr)
est store manu_noAuto_noTex


outreg2 [baseline manu manu_noAuto manu_noAuto_noTex] using "FigD3Data.xls", append keep($TWITEXP) addtext("FSize x year FE, yes, Firm FE, yes, NAICS1 x Year, yes")  nocons dec(3) dta


coefplot (baseline, label("Baseline: All GVCs")  msymbol(D) msize(medium) lcolor(olive) mcolor(olive) ciopts(lcolor(olive)) offset(-0.10) ) ///
(manu, label("Manufacturing GVC")  msymbol(O) msize(medium) lcolor(blue) mcolor(blue) ciopts(lcolor(blue)) offset(-0.05) )  ///
(manu_noAuto, label("Manufacturing without Automotive")  msymbol(S) msize(medium) lcolor(sand) mcolor(sand) ciopts(lcolor(sand)) offset(0.05)) ///
(manu_noAuto_noTex, label("Manufacturing without Automotive and Textile")  msymbol(X) msize(medium) lcolor(ltblue) mcolor(ltblue) ciopts(lcolor(ltblue)) offset(0.10)), ///
keep($TWITEXP_Coefs ) vertical omit graphregion(fcolor(white) lcolor(white)) coeflabels(, angle(45)) yline(0,  lpattern(solid))  /// 
ytitle("Dep. Var. Log US Exports""Firms' Exposure to US Tariffs on China") legend(cols(1) ring(0) pos(11) size(small))  nooffset ylabel(-1.5 (0.5) 2.25)  
graph export "FigureD3.pdf", replace



preserve
	


**Figure C.4 Quarterly Data

use "S:/Datos/EstSampleQuarterly.dta", clear

global TWITEXP"TWITExp_A0_224 TWITExp_A0_225 TWITExp_A0_226 TWITExp_A0_227 TWITExp_A0_228 TWITExp_A0_229 TWITExp_A0_230 TWITExp_A0_231 TWITExp_A0_232 TWITExp_A0_233 TWITExp_A0_234 TWITExp_A0_235 TWITExp_A0_236 TWITExp_A0_237 TWITExp_A0_238 TWITExp_A0_239 TWITExp_A0_240 TWITExp_A0_241 TWITExp_A0_242 TWITExp_A0_243 TWITExp_A0_244 TWITExp_A0_245 TWITExp_A0_246 TWITExp_A0_247"


global TWRTExp"TWRTExp_A0_224 TWRTExp_A0_225 TWRTExp_A0_226 TWRTExp_A0_227 TWRTExp_A0_228 TWRTExp_A0_229 TWRTExp_A0_230 TWRTExp_A0_231 TWRTExp_A0_232 TWRTExp_A0_233 TWRTExp_A0_234 TWRTExp_A0_235 TWRTExp_A0_236 TWRTExp_A0_237 TWRTExp_A0_238 TWRTExp_A0_239 TWRTExp_A0_240 TWRTExp_A0_241 TWRTExp_A0_242 TWRTExp_A0_243 TWRTExp_A0_244 TWRTExp_A0_245 TWRTExp_A0_246 TWRTExp_A0_247"


global TWITMex"TWITExpUS_Mex_224 TWITExpUS_Mex_225 TWITExpUS_Mex_226 TWITExpUS_Mex_227 TWITExpUS_Mex_228 TWITExpUS_Mex_229 TWITExpUS_Mex_230 TWITExpUS_Mex_231 TWITExpUS_Mex_232 TWITExpUS_Mex_233 TWITExpUS_Mex_234 TWITExpUS_Mex_235 TWITExpUS_Mex_236 TWITExpUS_Mex_237 TWITExpUS_Mex_238 TWITExpUS_Mex_239 TWITExpUS_Mex_240 TWITExpUS_Mex_241 TWITExpUS_Mex_242 TWITExpUS_Mex_243 TWITExpUS_Mex_244 TWITExpUS_Mex_245 TWITExpUS_Mex_246 TWITExpUS_Mex_247"


global TWRTMex"TWRTImpUS_Mex_224 TWRTImpUS_Mex_225 TWRTImpUS_Mex_226 TWRTImpUS_Mex_227 TWRTImpUS_Mex_228 TWRTImpUS_Mex_229 TWRTImpUS_Mex_230 TWRTImpUS_Mex_231 TWRTImpUS_Mex_232 TWRTImpUS_Mex_233 TWRTImpUS_Mex_234 TWRTImpUS_Mex_235 TWRTImpUS_Mex_236 TWRTImpUS_Mex_237 TWRTImpUS_Mex_238 TWRTImpUS_Mex_239 TWRTImpUS_Mex_240 TWRTImpUS_Mex_241 TWRTImpUS_Mex_242 TWRTImpUS_Mex_243 TWRTImpUS_Mex_244 TWRTImpUS_Mex_245 TWRTImpUS_Mex_246 TWRTImpUS_Mex_247"



reghdfe lnUSAExport $TWITEXP $TWRTExp $TWITMex $TWRTMex if IMM_Ref==1, vce(cluster ID) absorb(ID_qt  qdate naics3_yr  hs2_qt )
est store usx_imm_ind3y
outreg2  using "FigC4Data.xls", append keep($TWITEXP) addtext("Firm x quarter FE, YES, QDate FE, YES, Naics3 x Year, YES, HS2 x QDate, YES")  nocons dec(3) dta label

coefplot usx_imm_ind3y,  label("Dep. Var. Log US Exports")  msymbol(Dh) msize(medium) lcolor(olive) mcolor(olive) ciopts(lcolor(olive))  keep($TWITEXP) vertical omit graphregion(fcolor(white) lcolor(white)) coeflabels(, angle(45)) yline(0,  lpattern(solid))  ///
xlabel(, angle(45) labsize(small)) levels(95) ytitle("Firms' Exposure to US Tariffs on China") nooffset legend(cols(1) ring(0) pos(11) size(small)) ylabel(-1.1 (0.5) 2.5)
graph export "FigureC4.pdf", replace

	
	
	
	

use "TableB1_dta", replace
export excel `filename', sheet(TableB1, modify) cell(A1)

capture erase "TableB1_dta.dta"
capture erase "TableB1.txt"
capture erase "TableB1.xls"	


use "FigB2Data_dta", replace
export excel `filename', sheet(FigureB2, modify) cell(A1)

use "FigB3Data_dta", replace
export excel `filename', sheet(FigureB3, modify) cell(A1)

use "FigB4Data_dta", replace
export excel `filename', sheet(FigureB4, modify) cell(A1)

use "FigB5Data_dta", replace
export excel `filename', sheet(FigureB5, modify) cell(A1)

use "FigB6Data_dta", replace
export excel `filename', sheet(FigureB6, modify)

forval i=2/6{
capture erase "FigB`i'Data_dta.dta"
capture erase "FigB`i'Data.txt"
capture erase "FigB`i'Data.xls"	
}





use "FigB7B8_dta", replace
export excel `filename', sheet(FigB7B8, modify)

capture erase "FigB7B8_dta.dta"

capture erase "FigB7B8.txt"

capture erase "FigB7B8.xls"



use "FigB9Data_dta", replace
export excel `filename', sheet(FigureB9, modify)


use "FigB10Data_dta", replace
export excel `filename', sheet(FigureB10, modify)


use "FigB11Data_dta", replace
export excel `filename', sheet(FigureB11, modify)

use "FigB12Data_dta", replace
export excel `filename', sheet(FigureB12, modify)

forval i=9/12{

capture erase "FigB`i'Data_dta.dta"

capture erase "FigB`i'Data.txt"

capture erase "FigB`i'Data.xls"
}





**Figure2-TableB2
use "TableB2_dta", replace
export excel `filename', sheet(TableB2, modify) cell(A1)

capture erase "TableB2_dta.dta"

capture erase "TableB2.txt"

capture erase "TableB2.xls"

use "TableB3_dta", replace
export excel `filename', sheet(TableB3, modify) cell(A1)

capture erase "TableB3_dta.dta"

capture erase "TableB3.txt"

capture erase "TableB3.xls"


use "TableB4_1_dta", replace
export excel `filename', sheet(TableB4, modify) cell(A1)
use "TableB4_2_dta", replace
export excel `filename', sheet(TableB4, modify) cell(A10)

forval i=1/2{
capture erase "TableB4_`i'_dta.dta"

capture erase "TableB4_`i'.txt"

capture erase "TableB4_`i'.xls"
}


use "TableB5_1_dta", replace
export excel `filename', sheet(TableB5, modify) cell(A1)
use "TableB5_2_dta", replace
export excel `filename', sheet(TableB5, modify) cell(A11)
use "TableB5_3_dta", replace
export excel `filename', sheet(TableB5, modify) cell(A21)
forval i=1/3{
capture erase "TableB5_`i'_dta.dta"

capture erase "TableB5_`i'.txt"

capture erase "TableB5_`i'.xls"
}

use "TableB6_dta", replace
export excel `filename', sheet(TableB6, modify) cell(A1)

capture erase "TableB6_dta.dta"

capture erase "TableB6.txt"

capture erase "TableB6.xls"



use "FigC4Data_dta", replace
export excel `filename', sheet(FigureC4, modify)

capture erase "FigC4Data_dta.dta"

capture erase "FigC4Data.txt"

capture erase "FigC4Data.xls"

forval i=1/3{
use "FigD`i'Data_dta", replace
export excel `filename', sheet(FigureD`i', modify)

capture erase "FigD`i'Data_dta.dta"

capture erase "FigD`i'Data.txt"

capture erase "FigD`i'Data.xls"
}





restore






